1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
public static double interlaceProbability(Channel c) {
int width = c.getWidth();
int height = c.getHeight();
// Compute Half Image (even)
Channel c2 = new Channel(width,height);
for (int x=0;x<width;x+=1) {
for (int y=0;y<height;y+=2) {
c2.setValue(x,y, c.getValue(x,y) );
c2.setValue(x,y+1, c.getValue(x,y) );
}
}
// Hessian Kernel
Hessian hessian = new Hessian(3,1.4);
// Compute continuity error for each pixels
double orig_error = 0;
double half_error = 0;
for (int x=0;x<width;x+=1) {
for (int y=0;y<height-1;y++) {
// original continuity error
double c_y0 = hessian.laplacian(c,x,y);
double c_y1 = hessian.laplacian(c,x,y+1);
orig_error += Math.abs( c_y0 - c_y1 );
// half image continuity error
double c2_y0 = hessian.laplacian(c2,x,y);
double c2_y1 = hessian.laplacian(c2,x,y+1);
half_error += Math.abs( c2_y0 - c2_y1 );
}
}
double interlaceProbability = 1.0 - half_error/(half_error+orig_error);
return interlaceProbability;
} |
Partager