}
RgbMaskedImage rgbInput = (RgbMaskedImage)imInput;
int wInput[] = rgbInput.getData();
int wBack[] = this.rgbBack.getData();
Gray8Image grayOut = new Gray8Image(
this.rgbBack.getWidth(),
this.rgbBack.getHeight());
byte bGray[] = grayOut.getData();
for (int i=0; i<imInput.getHeight(); i++) {
for (int j=0; j<imInput.getWidth(); j++) {
if (!rgbInput.isMasked(i, j) && !this.rgbBack.isMasked(i,j)) {
int rIn = RgbVal.getR(wInput[i*grayOut.getWidth()+j]);
int gIn = RgbVal.getG(wInput[i*grayOut.getWidth()+j]);
int bIn = RgbVal.getB(wInput[i*grayOut.getWidth()+j]);
int rBack = RgbVal.getR(wBack[i*grayOut.getWidth()+j]);
int gBack = RgbVal.getG(wBack[i*grayOut.getWidth()+j]);
int bBack = RgbVal.getB(wBack[i*grayOut.getWidth()+j]);
int gRes = Math.abs(rIn-rBack) +
Math.abs(gIn-gBack) +
Math.abs(bIn-bBack);
bGray[i*grayOut.getWidth()+j] =
(byte) Math.min(gRes, Byte.MAX_VALUE);
} else {
bGray[i] = Byte.MIN_VALUE;
}
}