JAI, JPEG2000 performance queries.

I have recently made a program that converted bmp images into JPEG2000 lossless images using JAI and RC1.0.

The images are 640x480. They seem to compress reasonably fast (~1 second per image) however when i then load them back into another program i created it takes ~15-20 seconds to read the image. Is this normal? I find it hard to believe that is the case as normally compression takes longer than decompression for most algorithms…

I slightly modified my code, by compressing using png instead of JPEG2000 and leaving the rest of my code as it is. The decompression speeds was much faster <1 second per frame. This leads me to believe that it is something internal to the JAI JPEG2000 codec which is slowing down.

I do need JPEG2000 as the images i am wanting to compress are “natural”.

Any suggestions as to why it is so slow? and ways to speed it up?

What platform are you running on?
Is the native library available for the JPEG 2000 codec?
Are you aware that the JAI Image IO Tools are RELEASED as 1.0 ? RC 1 is old.
In fact 1.0_01 beta is available now.

http://java.sun.com/products/java-media/jai/index.jsp

One of the changes from 1.0 to 1.0_01 beta is:
“When both the native and Java plug-ins are available, the native reader has higher registry precedence than the Java reader, and the native writer higher precedence than the Java writer.”

I suspect the 1.0 version has the native JPEG2000 reader at a lower precedence than the Java version.

Yep - I think that’s it:

http://developer.java.sun.com/developer/bugParade/bugs/4966663.html

“JPEG 2000 reader and writer plug-ins have random precedence order”

Is fixed in the _01 beta release.

I am currently using JDK 1.4_03 on windows

I have put the dll in the directory that was suggested in the installation notes.

I didnt know that there was a newer version…I will download the latest beta and see if that speeds up the reading of the JPEG2000.

Thanks for the suggestions.

Thanks again!

The latest beta solved my problem!

It is a little disturbing that the PNG writer creates files that are quite large as compared to other programs. But that is not a major complaint :slight_smile:

There may be parameters for the PNG writer that set the compression level. It could also be that other porgrams are smart enough to reduce the bits per pixel to the minimum required (using a palette format). If you are writing 24bit or 32 bit images without handling these issues I bet the PNG actually does use the full 24 or 32 bits per pixel and compresses that. If your image only has a small number of unique colours a palette based format would be more suitable for compression, but the PNG writer likely only does that for INDEXed colour models.

Yes, that is what i thought at first, however i cannot find how to change the parameters for the compression of PNG unless it is totally different to the way you change the parameters for JPEG2000.

Most of the images will not be able to be palettized, i.e. the will use most of the full spectrum of colour.

http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_0_01-beta-docs/overview-summary.html#PNGImageWriteParam

[quote]http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_0_01-beta-docs/overview-summary.html#PNGImageWriteParam
[/quote]
Lol!

I forgot to update my JAI API docs! that is why i could not find the appropriate WriteParam!

Thanks for pointing out that silly mistake to me!