Details
Description
Update the CCITTFax example to use some very cool interpolation algorithms in JAI to generate a better quality black and white image capture. The image operation is as follow:
// JAI filter code
LookupTableJAI lut = new LookupTableJAI(new byte[][]{{(byte) 0x00,
(byte) 0xff}, {(byte) 0x00, (byte) 0xff}, {(byte) 0x00, (byte) 0xff}});
ImageLayout layout = new ImageLayout();
byte[] map = new byte[]{(byte) 0x00, (byte) 0xff};
ColorModel cm = new IndexColorModel(1, 2, map, map, map);
layout.setColorModel(cm);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
surrogateImage.getWidth(),
surrogateImage.getHeight(),
1);
layout.setSampleModel(sm);
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
PlanarImage op = ErrorDiffusionDescriptor.create(surrogateImage, lut,
KernelJAI.ERROR_FILTER_FLOYD_STEINBERG, hints);
BufferedImage dst = op.getAsBufferedImage();
// JAI filter code
LookupTableJAI lut = new LookupTableJAI(new byte[][]{{(byte) 0x00,
(byte) 0xff}, {(byte) 0x00, (byte) 0xff}, {(byte) 0x00, (byte) 0xff}});
ImageLayout layout = new ImageLayout();
byte[] map = new byte[]{(byte) 0x00, (byte) 0xff};
ColorModel cm = new IndexColorModel(1, 2, map, map, map);
layout.setColorModel(cm);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
surrogateImage.getWidth(),
surrogateImage.getHeight(),
1);
layout.setSampleModel(sm);
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
PlanarImage op = ErrorDiffusionDescriptor.create(surrogateImage, lut,
KernelJAI.ERROR_FILTER_FLOYD_STEINBERG, hints);
BufferedImage dst = op.getAsBufferedImage();
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
Example has been updated with some very nice results. Now that CCITT T.4 is beeing used over the previous "JPEG" tiff compression the resulting image capture size is significantly small. Not very often you get more for less.