Skip to main content

[JAI] LUT and SampleModel

3 replies [Last post]
Anonymous

Hi !

I?d like to know how to recognize images which were created with a lookup
table.

I thought I could check if the image?s colorModel is an IndexColorModel, but
sometimes, getColorModel() returns null, so it isn?t reliable?

The solution I use for the moment is to check if the sampleModel is a
MultiPixelPackedSampleModel.

That seems to work fine, but I don?t really know if this is the good
solution ?

Can someone provide me some more information about this ?

Thanks a lot !

Stephane

[att1.html]

Reply viewing options

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

What do you intend by "images which were created with a lookup table"?

On Tue, 18 Oct 2005, Stéphane WASSERHARDT wrote:

> Hi !
>
>
>
> IÂ’d like to know how to recognize images which were created with a lookup
> table.
>
> I thought I could check if the imageÂ’s colorModel is an IndexColorModel, but
> sometimes, getColorModel() returns null, so it isnÂ’t reliableÂ…
>
> The solution I use for the moment is to check if the sampleModel is a
> MultiPixelPackedSampleModel.
>
> That seems to work fine, but I donÂ’t really know if this is the good
> solution Â…
>
> Can someone provide me some more information about this ?
>
>
>
> Thanks a lot !
>
> Stephane
>
>

----------------
Brian Burkhalter
Java Multimedia, 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.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Stéphane WASSERHARDT

For me a lookup table indicates images using an IndexColorModel (maybe I'm
wrong ...)
In fact, I just want to know it's possible to recognize an image which uses
an IndexColorModel without accessing the ColorModel itself... Because for
some of my images, getColorModel returns null.

Here is my current code :

ColorModel cm = img.getColorModel();
if ((cm != null) && (cm instanceof IndexColorModel)) {
// do something with IndexColorModel
}
Else {
// do sth without IndexColorModel
}

But if cm is null, this will fail ..
So what can I add to my "if" clause to get the right result ?
Or perhaps there's a method which can force the color model of the image to
be computed so that calling getColorModel afterwards won't return null...

Thanks for your help !
Stéphane

-----Message d'origine-----
De : Brian.Burkhalter@Sun.COM [mailto:Brian.Burkhalter@Sun.COM]
Envoyé : mardi 18 octobre 2005 19:14
À : JAI
Objet : Re: [JAI] LUT and SampleModel

What do you intend by "images which were created with a lookup table"?

On Tue, 18 Oct 2005, Stéphane WASSERHARDT wrote:

> Hi !
>
>
>
> IÂ’d like to know how to recognize images which were created with a lookup
> table.
>
> I thought I could check if the imageÂ’s colorModel is an IndexColorModel,
but
> sometimes, getColorModel() returns null, so it isnÂ’t reliableÂ…
>
> The solution I use for the moment is to check if the sampleModel is a
> MultiPixelPackedSampleModel.
>
> That seems to work fine, but I donÂ’t really know if this is the good
> solution Â…
>
> Can someone provide me some more information about this ?
>
>
>
> Thanks a lot !
>
> Stephane
>
>

----------------
Brian Burkhalter
Java Multimedia, 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.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

On Wed, 19 Oct 2005, Stéphane WASSERHARDT wrote:

> For me a lookup table indicates images using an IndexColorModel (maybe I'm
> wrong ...)
> In fact, I just want to know it's possible to recognize an image which uses
> an IndexColorModel without accessing the ColorModel itself... Because for
> some of my images, getColorModel returns null.

In general an image should be colormapped if and only if it has an
IndexColorModel. If the ColorModel is null, then it is not colormapped. The
only exception to this rule that I can think of would be some implicit mapping
of single band (one sample per pixel) images to the [0,255] range. For example
the index i might be mapped to i*255/((1 << bitsPerSample) - 1). For example,
javax.media.jai.widget.ImageCanvas does this for bilevel images which have a
null ColorModel.

> Here is my current code :
>
> ColorModel cm = img.getColorModel();
> if ((cm != null) && (cm instanceof IndexColorModel)) {
> // do something with IndexColorModel
> }
> Else {
> // do sth without IndexColorModel
> }
>
> But if cm is null, this will fail ..

Why does it fail? I must be missing something ...

Brian

> So what can I add to my "if" clause to get the right result ?
> Or perhaps there's a method which can force the color model of the image to
> be computed so that calling getColorModel afterwards won't return null...
>
> Thanks for your help !
> Stéphane
>
> -----Message d'origine-----
> De : Brian.Burkhalter@Sun.COM [mailto:Brian.Burkhalter@Sun.COM]
> Envoyé : mardi 18 octobre 2005 19:14
> À : JAI
> Objet : Re: [JAI] LUT and SampleModel
>
> What do you intend by "images which were created with a lookup table"?
>
> On Tue, 18 Oct 2005, Stéphane WASSERHARDT wrote:
>
>> Hi !
>>
>>
>>
>> IÂ’d like to know how to recognize images which were created with a lookup
>> table.
>>
>> I thought I could check if the imageÂ’s colorModel is an IndexColorModel,
> but
>> sometimes, getColorModel() returns null, so it isnÂ’t reliableÂ…
>>
>> The solution I use for the moment is to check if the sampleModel is a
>> MultiPixelPackedSampleModel.
>>
>> That seems to work fine, but I donÂ’t really know if this is the good
>> solution Â…
>>
>> Can someone provide me some more information about this ?
>>
>>
>>
>> Thanks a lot !
>>
>> Stephane
>>
>>
>
> ----------------
> Brian Burkhalter
> Java Multimedia, 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.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Java Multimedia, 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.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net