BufferedImage alpha = new BufferedImage(img.getWidth(), img.getHeight(),
BufferedImage.TYPE_BYTE_GRAY);
Raster raster = img.getData();
GraphicsUtil.copyBand(raster, cm.getNumColorComponents(), alpha.getRaster(), 0);
BufferedImageOp op1 = new LookupOp(new ByteLookupTable(0, THRESHOLD_TABLE), null);
BufferedImage alphat = op1.filter(alpha, null);
BufferedImage mask;
if (true) {
mask = new BufferedImage(targetDim.width, targetDim.height,