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(),
null,
null);
}
this.imageCropped = (Gray8Image) imageResult;
{ Debug debug = new Debug();
Gray8Rgb g2r = new Gray8Rgb();
g2r.push(this.imageCropped);
RgbImage rgb = (RgbImage) g2r.getFront();
debug.toFile(rgb, "cropped.png"); //$NON-NLS-1$
}
/* Then do edge detection. The cWidth of the Canny operator is set
* based on the cropped cWidth, which is supposed to be the
* barcode cWidth.
*/
int cCannyWidth = cWidth / 6;
Gray8CannyHoriz canny = new Gray8CannyHoriz(cCannyWidth);
/* Now apply the edge detection to the cropped mage
*/
canny.push(imageCropped.clone());
/* And obtain the result
*/
imageResult = canny.getFront();
if (!(imageResult instanceof Gray8Image)) {
throw new jjil.core.Error(
jjil.core.Error.PACKAGE.ALGORITHM,
jjil.algorithm.ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
imageResult.toString(),
null,
null);
}
this.imageEdge = (Gray8Image) imageResult;
{