int cWidth,
int cHeight) throws jjil.core.Error
{
/* Build an image pipeline to do the work.
*/
Sequence seq = new Sequence();
/* First convert the color image to black and white by selecting the
* green channel. We use the green channel because it is the highest
* resolution channel on the CCDs used in cellphones.
*/
if (image instanceof RgbImage) {
seq.add(new RgbSelectGray(RgbSelectGray.GREEN));
}
/* Now crop the gray image.
*/
int dLeft = Math.max(0, dTopLeftX - cWidth / 12);
int cWidthExp = Math.min(image.getWidth() - dLeft, cWidth * 7 / 6);
seq.add(new Gray8Crop(dLeft, dTopLeftY, cWidthExp, cHeight));
/* Apply the pipeline to get the cropped image.
*/
seq.push(image);
Image imageResult = seq.getFront();
if (!(imageResult instanceof Gray8Image)) {
throw new jjil.core.Error(
jjil.core.Error.PACKAGE.ALGORITHM,
jjil.algorithm.ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
imageResult.toString(),