Re: JPEG2000 compression [message #43461 is a reply to message #41151] |
Wed, 13 April 2005 16:27   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
Roberto Monaco wrote:
>>> I have a question regarding JPEG2000:
>>>
>>> How do you control compression ratio when you save an image as JPEG2000
>>> using the IDL object?
>>
>> Looks like the N_LEVELS property.
>
>
> Yes, from the documentation you would expect N_LEVELS to be responsible for
> compression.
>
> This is the code I am using:
> jp2 = obj_new('IDLffJPEG2000', jp2_file, /WRITE)
> jp2->SetProperty, N_LEVELS=15
> jp2->SetProperty, TILE_DIMENSIONS=[2048.,2048.]
> jp2->SetData, image, /ORDER
> obj_destroy, jp2
>
> If I set N_LEVELS to 5 in the second line (the default) and run it again for
> the same image (same input file) I get both times jp2 files of the same
> dimension (31 MB) ?!?! I am obviously missing something here.
Well, it works for me:
jp2 = obj_new('IDLffJPEG2000', 'test1.jp2', /WRITE)
jp2->SetProperty, N_LEVELS=0
jp2->SetData, BYTSCL(DIST(1600,1200))
obj_destroy, jp2
jp2 = obj_new('IDLffJPEG2000', 'test2.jp2', /WRITE)
jp2->SetProperty, N_LEVELS=15
jp2->SetData, BYTSCL(DIST(1600,1200))
obj_destroy, jp2
test1.jp2 is 614KB
test2.jp2 is 13KB
Further, querying the image works as advertised too:
jp2 = obj_new('IDLffJPEG2000', 'test1.jp2', /READ)
jp2->GetProperty, N_LEVELS=nl
PRINT, nl
obj_destroy, jp2
% Compiled module: $MAIN$.
IDL> .GO
0
jp2 = obj_new('IDLffJPEG2000', 'test2.jp2', /READ)
jp2->GetProperty, N_LEVELS=nl
PRINT, nl
obj_destroy, jp2
% Compiled module: $MAIN$.
IDL> .GO
15
>> Well, I know nothing about JPEG2000 but I would hope that all of the
>> properties that you have specified *would* be identical. The only
>> property that should change would be the compression factor. Don't know
>> where that would be though. Maybe the N_LEVELS property again? Don't
>> know if that would be set after reading a file or if it only applies to
>> writing.
>
>
> These images were created ouside IDL, in Photoshop saving the same TIFF
> image as JP2 using different compression ratios each time. Afterwards when I
> read them within IDL I would expect to see differences in their properties,
> since one corresponds to 1:1 (~30 MB of data) and another to 1:40 (~3 MB of
> data). But N_LEVELS, as ALL the other properties, are exactly the same for
> all cases...
Why do you think it is a problem that "ALL the other properties" are
exactly the same if you have taken the same image and saved it multiple
times, only changing the "compression factor"? What other properties
should change?
My point was that I would assume that the image dimensions, color space,
n_layers, offset and the other properties *wouldn't* change if you only
changed the "compression factor" in photoshop.
> By the way there is no compression property in 'IDLffJPEG2000' object
> structure.
I know. I was relating N_LEVELS to what you called "compression factor"
in photoshop.
-Rick
|
|
|