?? haar.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 + -