You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Michael Voyes <qm...@ocegr.fr> on 2004/11/08 14:18:34 UTC

Bilevel requires more time than Grayscale to encode ...


I used the TiledImageTranscoder Class lying into the Contrib directory 
of the Batik sources and i find something strange.
As everybody knows, by default, Batik works in ARGB colorspace, then, if 
you decide to encode your RenderedImage into different colorspace, you 
have to modify it by yourself like following :

from ARGB to GRAY:
buf = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_GRAY);
mFirstImage = new FormatRed (GraphicsUtil.wrap(result), 
buf.getColorModel());

from ARGB to Bilevel:
buf = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_BINARY);
mFirstImage = new FormatRed (GraphicsUtil.wrap(result), 
buf.getColorModel());

Here is the modified TiledImageTranscoder Class snipet considering the 
colorspace modification

TiledImageTranscoder Class modified:
....
int bands = img.getSampleModel().getNumBands();
int [] off = new int[bands];
for (int i=0; i<bands; i++)
    off[i] = i;
SampleModel sm = new PixelInterleavedSampleModel (DataBuffer.TYPE_BYTE, 
w, (100000+w-1)/w,  bands, w*bands, off);
RenderedImage rimg = new FormatRed(GraphicsUtil.wrap(img), sm);

TIFFImageEncoder enc = new TIFFImageEncoder(output.getOutpustream(), null);

BufferedImage buf1 = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_GRAY);
RenderedImage mGrayImage= new FormatRed (GraphicsUtil.wrap(rimg ), 
buf1.getColorModel());

enc.encode(mGrayImage);

BufferedImage  buf2 = new BufferedImage(1,1, 
BufferedImage.TYPE_BYTE_BINARY);
RenderedImage mBilevelImage= new FormatRed (GraphicsUtil.wrap(rimg ), 
buf2.getColorModel());

enc.encode(mBilevelImage);
...

There, you could find that mBilevelImage takes more time to encode than 
mGrayImage, things that i could not understand ... does the 
mBilevelImage more simpliest image than mGrayImage and therefore easier 
to encode?


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Bilevel requires more time than Grayscale to encode ...

Posted by Thomas DeWeese <Th...@Kodak.com>.
Michael Voyes wrote:

> [...]
> There, you could find that mBilevelImage takes more time to encode than 
> mGrayImage, things that i could not understand ... does the 
> mBilevelImage more simpliest image than mGrayImage and therefore easier 
> to encode?

Hi Michael,

    This isn't that surprising to me.  When you go to bilevel it needs
to do an extra step called 'dithering' which can be an expensive
operation.  Also it is very likely that packing/unpacking the bi-level
bits is not very well optimized in the Tiff Encoder or Java2D.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org