www.pudn.com > wavecode.rar > haar.c
#include#include #include #include 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) >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) >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; } } } } }