Skip to main content

J2K Lossy Decomposition Levels

13 replies [Last post]
justinfalk
Offline
Joined: 2008-05-21
Points: 0

Hello,

I'm using the J2K image writer (codec) to perform lossy compression on uncompressed medical images. I have found that often times the images are over-compressed as to make them unusable. This seems to depend on the number of decomposition levels specified. For example, things generally work well for CT images (512x512, 16 bit, MONOCHROME2) when I use a value of 8 for decomposition levels. However, if I use a value of 10 about a third of the images are over-compressed by a factor of 2 and there are artifacts in the images. When I use CR images (2048x2500, 16 bits allocated, 12 bits stored, MONOCHROME2) it appears to work better with a value of 12 for decomposition levels.

Questions:
Is there a rule of thumb for determining the appropriate number of decomposition levels to use when encoding an image?
Would such a rule be based on image size? Bits per pixel? Something else?
Why does the file size vary drastically based on the decomposition levels despite compressionQuality remaining constant? Should a .2 compression quality mean the image size will be roughly 20% of the original uncompressed image?

Any input would be appreciated.

Thanks,

Justin

Reply viewing options

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

To be honest, I did a cursory read at

http://www.gvsu.edu/math/wavelets/student_work/EF/index.html

and am uncertain that the number of decomposition levels needs to be
set, but rather the bit rate can control the compression level needed.

The decomposition levels makes extracting sub images possible ???

I think that leaving it at 5, and just adjusting the bit rate
(quality) is all that is needed.

On Jun 25, 2008, at 7:58 PM, jai-imageio@javadesktop.org wrote:

> Robert,
>
> Thanks for the response. I'm aware of bug 150... you gave me a
> patch for it yesterday. :) I would love for the plugin to
> determine the number of levels and bitrate. How do I do that? The
> problem I have is the numDecompositionLevels defaults to a value of
> 5 if not set. So for larger images I have to manually set the
> number of decomposition levels to a value greater than 5. Is there
> a better way to do this?
>
> Thanks,
>
> Justin
> [Message sent by forum member 'justinfalk' (justinfalk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282653
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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

justinfalk
Offline
Joined: 2008-05-21
Points: 0

"I think that leaving it at 5, and just adjusting the bit rate
(quality) is all that is needed."

I really wish that were true. Unfortunately, at certain decomposition levels the quality factor is ignored and the image size is the same every time (except at compressionQuality=1.0). Is this a bug?

Justin

robert engels

I would think that more decompression levels is going to give you a
larger image at the same bit rate.

Someone that understands j2k better would be of more help.

On Jun 25, 2008, at 8:30 PM, jai-imageio@javadesktop.org wrote:

> "I think that leaving it at 5, and just adjusting the bit rate
> (quality) is all that is needed."
>
> I really wish that were true. Unfortunately, at certain
> decomposition levels the quality factor is ignored and the image
> size is the same every time (except at compressionQuality=1.0). Is
> this a bug?
>
> Justin
> [Message sent by forum member 'justinfalk' (justinfalk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282659
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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

justinfalk
Offline
Joined: 2008-05-21
Points: 0

"I would think that more decompression levels is going to give you a
larger image at the same bit rate."

Generally, this is true. However, at a certain number of decomposition levels the image size seems to get "stuck" at a certain size. For example, I have two 512x512 images. Both of them compress correctly with numDecompositionLevels set to 0 or 8. However, if I set it to 7 or 12 one of them only comes out with a file size of 35k regardless of the compression quality passed in. Then I have a larger image that only compresses correctly at with a value of 12.

Justin

robert engels

Can you email me the images with the exact details, and I can try it
out...

On Jun 25, 2008, at 8:51 PM, jai-imageio@javadesktop.org wrote:

> "I would think that more decompression levels is going to give you a
> larger image at the same bit rate."
>
> Generally, this is true. However, at a certain number of
> decomposition levels the image size seems to get "stuck" at a
> certain size. For example, I have two 512x512 images. Both of
> them compress correctly with numDecompositionLevels set to 0 or 8.
> However, if I set it to 7 or 12 one of them only comes out with a
> file size of 35k regardless of the compression quality passed in.
> Then I have a larger image that only compresses correctly at with a
> value of 12.
>
> Justin
> [Message sent by forum member 'justinfalk' (justinfalk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282661
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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

justinfalk
Offline
Joined: 2008-05-21
Points: 0

Robert,

Yes, I can convert the DICOM images to BMP and email them to you. I'll also include the settings I used for compression quality and decomposition levels. What is your email address? Or is there a way to attach them in the forum?

Thanks,

Justin

robert engels

Do you have a public ftp site or somewhere I can pull them from?

On Jun 26, 2008, at 12:40 PM, jai-imageio@javadesktop.org wrote:

> Robert,
>
> Yes, I can convert the DICOM images to BMP and email them to you.
> I'll also include the settings I used for compression quality and
> decomposition levels. What is your email address? Or is there a
> way to attach them in the forum?
>
> Thanks,
>
> Justin
> [Message sent by forum member 'justinfalk' (justinfalk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282826
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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

justinfalk
Offline
Joined: 2008-05-21
Points: 0

No I don't but the zip with the two images is only about 100k so it should be that bad to email. I'm surprised this forum doesn't allow attachments.

Justin

robertengels
Offline
Joined: 2004-05-24
Points: 0

Oops, just sent you a duplicate request. Wasn't aware it was the same general issue...

robert engels

Also, your problem may be affect by bug 150 - you should read this.

On Jun 25, 2008, at 7:31 PM, jai-imageio@javadesktop.org wrote:

> Hello,
>
> I'm using the J2K image writer (codec) to perform lossy compression
> on uncompressed medical images. I have found that often times the
> images are over-compressed as to make them unusable. This seems to
> depend on the number of decomposition levels specified. For
> example, things generally work well for CT images (512x512, 16 bit,
> MONOCHROME2) when I use a value of 8 for decomposition levels.
> However, if I use a value of 10 about a third of the images are
> over-compressed by a factor of 2 and there are artifacts in the
> images. When I use CR images (2048x2500, 16 bits allocated, 12
> bits stored, MONOCHROME2) it appears to work better with a value of
> 12 for decomposition levels.
>
> Questions:
> Is there a rule of thumb for determining the appropriate number of
> decomposition levels to use when encoding an image?
> Would such a rule be based on image size? Bits per pixel?
> Something else?
> Why does the file size vary drastically based on the decomposition
> levels despite compressionQuality remaining constant? Should a .2
> compression quality mean the image size will be roughly 20% of the
> original uncompressed image?
>
> Any input would be appreciated.
>
> Thanks,
>
> Justin
> [Message sent by forum member 'justinfalk' (justinfalk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282648
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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

justinfalk
Offline
Joined: 2008-05-21
Points: 0

Robert,

Thanks for the response. I'm aware of bug 150... you gave me a patch for it yesterday. :) I would love for the plugin to determine the number of levels and bitrate. How do I do that? The problem I have is the numDecompositionLevels defaults to a value of 5 if not set. So for larger images I have to manually set the number of decomposition levels to a value greater than 5. Is there a better way to do this?

Thanks,

Justin

justinfalk
Offline
Joined: 2008-05-21
Points: 0

Nevermind, I spoke too soon. Setting the number of levels to 0 worked for the smaller images but not the larger ones.

Message was edited by: justinfalk

robert engels

I would use the standard quality factor, and let the plugin determine
the number of levels & bit rate.

On Jun 25, 2008, at 7:31 PM, jai-imageio@javadesktop.org wrote:

> Hello,
>
> I'm using the J2K image writer (codec) to perform lossy compression
> on uncompressed medical images. I have found that often times the
> images are over-compressed as to make them unusable. This seems to
> depend on the number of decomposition levels specified. For
> example, things generally work well for CT images (512x512, 16 bit,
> MONOCHROME2) when I use a value of 8 for decomposition levels.
> However, if I use a value of 10 about a third of the images are
> over-compressed by a factor of 2 and there are artifacts in the
> images. When I use CR images (2048x2500, 16 bits allocated, 12
> bits stored, MONOCHROME2) it appears to work better with a value of
> 12 for decomposition levels.
>
> Questions:
> Is there a rule of thumb for determining the appropriate number of
> decomposition levels to use when encoding an image?
> Would such a rule be based on image size? Bits per pixel?
> Something else?
> Why does the file size vary drastically based on the decomposition
> levels despite compressionQuality remaining constant? Should a .2
> compression quality mean the image size will be roughly 20% of the
> original uncompressed image?
>
> Any input would be appreciated.
>
> Thanks,
>
> Justin
> [Message sent by forum member 'justinfalk' (justinfalk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282648
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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