Skip to main content

JPEG Lossless 8/12 bit

5 replies [Last post]
cij100
Offline
Joined: 2007-05-12

I'm currently generating Lossless-JPEG files which are causing a test tool to fail, however I know it works with 12 bit lossless images sourced from an external source. I've had a look at the api but I couldn't see an easy way to force the writer to write out a 12bit lossless image instead of the current 8bit, but maybe I missed it.

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

Assuming that you have JAI Image I/O Tools installed you should be able to
specify this via the ImageWriteParam

ImageWriterParam wparam;
wparam.setCompressionMode(wparam.MODE_EXPLICIT);
wparam.setCompressionType("JPEG-LS");

You would need to pass this wparam to the writer.

On Tue, 26 Jun 2007, jai-imageio@javadesktop.org wrote:

> I'm currently generating Lossless-JPEG files which are causing a test tool to fail, however I know it works with 12 bit lossless images sourced from an external source. I've had a look at the api but I couldn't see an easy way to force the writer to write out a 12bit lossless image instead of the current 8bit, but maybe I missed it.
>
> Thanks.
> [Message sent by forum member 'cij100' (cij100)]
>
> http://forums.java.net/jive/thread.jspa?messageID=223964

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

cij100
Offline
Joined: 2007-05-12

Hi Brian,

Yes I'm using the Image I/O tools. As I understood it, the JPEG-LS (ISO-14495-1/ITU-T.87) algorithm was different to the JPEG-LOSSLESS (ISO-10918-1/ITU-T.81) algorithm? For this application I need to use the LOSSLESS and not the LS algorithm. my current code looks like:

ImageWriteParam iw_param = writer.getDefaultWriteParam();
iw_param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iw_param.setCompressionType("JPEG-LOSSLESS");
iw_param.setCompressionQuality(1.0f);

The image io page states that 2-16bit lossless jpegs can be created using JPEG-LOSSLESS, is this just based upon the bit depth of the colormodel? Based upon my test image (8bit depth in the colormodel) and the above code, I get an 8 bit lossless jpeg.

Thanks.

Brian Burkhalter

> Yes I'm using the Image I/O tools. As I understood it, the JPEG-LS
> (ISO-14495-1/ITU-T.87) algorithm was different to the JPEG-LOSSLESS
> (ISO-10918-1/ITU-T.81) algorithm?

Yes.

> For this application I need to use the LOSSLESS and not the LS algorithm.

Too bad. I think the compression ratio is generally not as good for that.

> my current code looks like:
>
> ImageWriteParam iw_param = writer.getDefaultWriteParam();
> iw_param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
> iw_param.setCompressionType("JPEG-LOSSLESS");
> iw_param.setCompressionQuality(1.0f);

I don't believe the quality setting is useful here. That value maps to the
contents of the Huffman and Quantization tables.

> The image io page states that 2-16bit lossless jpegs can be created using
> JPEG-LOSSLESS, is this just based upon the bit depth of the colormodel?

Yes. To be specific the code is this

int bitDepth = renderedImage.getColorModel().getComponentSize(0);

where 'renderedImage' is the one you are trying to write.

> Based upon my test image (8bit depth in the colormodel) and the above code,
> I get an 8 bit lossless jpeg.

Correct.

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

cij100
Offline
Joined: 2007-05-12

Ok, that all makes sense, thanks for your help.

Is there a recomended way of converting a colormodel between two bit depths, in this case it's from 8 to 12 bit. In the past I have used the JAI format and rescale commands, but they only really work when the bit depth corresponds to a databuffer type (ie 8 (byte), 16(UShort) etc. I'm unsure about the best way to create one containing data of an intermediate size.

Thanks

Chris

Brian Burkhalter

On Tue, 26 Jun 2007, jai-imageio@javadesktop.org wrote:

> Ok, that all makes sense, thanks for your help.
>
> Is there a recomended way of converting a colormodel between two bit depths, in this case it's from 8 to 12 bit. In the past I have used the JAI format and rescale commands, but they only really work when the bit depth corresponds to a databuffer type (ie 8 (byte), 16(UShort) etc. I'm unsure about the best way to create one containing data of an intermediate size.

I am not sure offhand how to go about this as the
CompnentColorModel.isCompatibleSampleModel(SampleModel) method requires that
the transferType of the SampleModel and ColorModel be the same.

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net