View Single Post
  #5 (permalink)  
Old 08-29-2008, 04:59 PM
Mazharul Mazharul is offline
Member
 
Join Date: Aug 2008
Posts: 9
Mazharul is on a distinguished road
// Spread error amongst neighbouring pixels

value = input.getSample(x+1, y, 0);
input.setSample(x+1, y, 0, clamp(value + 0.4375f * error));
//Error is here
value = input.getSample(x-1, y+1, 0);
input.setSample(x-1, y+1, 0, clamp(value + 0.1875f * error));
value = input.getSample(x, y+1, 0);
input.setSample(x, y+1, 0, clamp(value + 0.3125f * error));
value = input.getSample(x+1, y+1, 0);
input.setSample(x+1, y+1, 0, clamp(value + 0.0625f * error));

}
sir...
values of the first 2 args in the call to getSample() at line 55 is pixel values which is situated at west-south conrner of (x,y) co-ordinate.

sir why error is not reported due to code fragment which is above of previous segment
WritableRaster input = inputImage.copyData(null);
WritableRaster output = outputImage.getRaster();
final int threshold = 128;
int value, error;

for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
//it is not reporting error
value = input.getSample(x, y, 0);
Reply With Quote