return new Vec2(x,y);
}
private Gray8Image warpX(Gray8Image grayIn) {
// allocate image. it is implicitly offset by nMinX
Gray8Image grayOut = new Gray8Image(
nMaxX - nMinX,
grayIn.getHeight(),
Byte.MIN_VALUE);
// pointer to input
byte[] bDataIn = grayIn.getData();
byte[] bDataOut = grayOut.getData();
for (int x = nMinX; x<nMaxX; x++) {
for (int y = 0; y<grayIn.getHeight(); y++) {
// calculate x in original image.
// nX is scaled by 2**16.
// y does not change but is offset by nYOffset
int nX = x * this.rnWarpX[0] +
this.rnWarpX[1] * (y + this.nYOffset) +
this.rnWarpX[2];
// nXfloor is the integer value of nX, unscaled
int nXfloor = nX >> 16;
// nXfrace is the fractional component of nX, scaled by 2**16
int nXfrac = nX - (nXfloor<<16);
// interpolate to get point
if (nXfloor >= 0 && nXfloor < grayIn.getWidth()-1) {
int bIn = bDataIn[y*grayIn.getWidth() + nXfloor];
int bInP1 = bDataIn[y*grayIn.getWidth() + nXfloor + 1];
int bOut = (bIn * ((1<<16)- nXfrac) +
bInP1 * nXfrac)>>16;
bDataOut[grayOut.getWidth()*y + x-nMinX] = (byte) bOut;
}
}
}
this.nXOffset = nMinX;
return grayOut;