⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 haar.c

📁 用C++语言实现的基于小波分析的源代码,实现了小波分析的诸多算法
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <crblib/inc.h>

void haar_Transform2D(int **rows, int width, int height, int levels,bool inverse)
{
int *plane,*line,*nextline;
int step,step2,x,y,ll_width;
int a,b,c,d,A,B,C,D;

	ll_width = width>>levels;
	plane = rows[0];

	if ( ! inverse ) {

		for(step=1;step<=ll_width;step<<=1) {
			step2 = step + step;
			for(y=0;(y+step)<height;y += step2) {
				line = plane + y*width;
				nextline = line + step*width;
				for(x=0;(x+step)<width;x += step2) {

					a = line[x]; b = line[x+step];
					c = nextline[x]; d = nextline[x+step];

					A = (a+b+c+d)>>2;
					B = a-b-c+d;
					C = a+b-c-d;
					D = a-b+c-d;

					line[x] 			= A; // will be coded in next pass
					line[x+step]		= B;
					nextline[x]			= C;
					nextline[x+step]	= D;
				}
			}
		}

	} else {

		/** go backwards in scale **/
		for(step=ll_width;step>=1;step>>=1) {
			step2 = step + step;

			for(y=0;(y+step)<height;y += step2) {

				line = plane + y*width;
				nextline = line + step*width;

				for(x=0;(x+step)<width;x += step2) {

					A = line[x]; // already decoded.
					B = line[x+step];
					C = nextline[x];
					D = nextline[x+step];

					a = A + ((3 + B + C + D)>>2);
					b = A + ((3 - B + C - D)>>2);
					c = A + ((3 - B - C + D)>>2);
					d = A + ((3 + B - C - D)>>2);

					line[x]			= a;
					line[x+step]	= b;
					nextline[x] 	= c;
					nextline[x+step]= d;
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -