Skip to main content

[JAI] RGB to YCC to RGB

5 replies [Last post]
Anonymous

Hello,
I'm working on watermarking, which involves modifying image data on
the frequency domain after converting it to YCC. My problem is the
following:
I get a YCC colorspace image (CS_PYCC), I convert it to its original
colorspace (RGB), and I store it. The problem is that when I open it
again and convert it to YCC I get different data. For example, the 4
first coefficients of the YCC image are 223, 5, 218, 66, which turn to
247, 3, 246, 247 in RGB. The issue is that when I try to convert them
to YCC again I get 205, 4, 202, 66, which is perceptually good enough,
but not good enough to evaluate watermarking...

Could someone help me?

Thanks in advance
--
Juan Ignacio S

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Stéphane Wasserhardt

I think you have to make sure you store the RGB image in a raw format
(without compression) !

-----Message d'origine-----
De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
Envoyé : lundi 23 mai 2005 10:53
À : interest@jai.dev.java.net
Objet : [JAI] RGB to YCC to RGB

Hello,
I'm working on watermarking, which involves modifying image data on
the frequency domain after converting it to YCC. My problem is the
following:
I get a YCC colorspace image (CS_PYCC), I convert it to its original
colorspace (RGB), and I store it. The problem is that when I open it
again and convert it to YCC I get different data. For example, the 4
first coefficients of the YCC image are 223, 5, 218, 66, which turn to
247, 3, 246, 247 in RGB. The issue is that when I try to convert them
to YCC again I get 205, 4, 202, 66, which is perceptually good enough,
but not good enough to evaluate watermarking...

Could someone help me?

Thanks in advance
--
Juan Ignacio Sánchez Lara
Ingeniero Técnico en Informática de Sistemas

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

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

Juan Ignacio Sánchez Lara

I actually store it in RGB, so no more conversion is produced... In
fact you see that the RGB values I read are the same that those I
store... I'm pretty convinced the problem is within the RGB->YCC
process is not the inverse of the YCC-> RGB (at least not the one I've
implemented).

This is the code of those steps:

public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel cm) {
ParameterBlock pb = new ParameterBlock();
pb.addSource(pi).add(cm);
pi = JAI.create("ColorConvert", pb, null);
return pi;
}

When I want to do an YCC->RGB conversion, cm is the original
ColorModel of the image. For the RGB->YCC, cm is obtained with the
following code:

public static ColorModel getPYCCColorModel() {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
int[] bits = { 8, 8, 8 };
ColorModel cm = new ComponentColorModel(cs, bits, false, false,
Transparency.OPAQUE,
DataBuffer.TYPE_BYTE);
return cm;
}

On 5/23/05, Stéphane Wasserhardt wrote:
> I think you have to make sure you store the RGB image in a raw format
> (without compression) !
>
> -----Message d'origine-----
> De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
> Envoyé : lundi 23 mai 2005 10:53
> À : interest@jai.dev.java.net
> Objet : [JAI] RGB to YCC to RGB
>
>
> Hello,
> I'm working on watermarking, which involves modifying image data on
> the frequency domain after converting it to YCC. My problem is the
> following:
> I get a YCC colorspace image (CS_PYCC), I convert it to its original
> colorspace (RGB), and I store it. The problem is that when I open it
> again and convert it to YCC I get different data. For example, the 4
> first coefficients of the YCC image are 223, 5, 218, 66, which turn to
> 247, 3, 246, 247 in RGB. The issue is that when I try to convert them
> to YCC again I get 205, 4, 202, 66, which is perceptually good enough,
> but not good enough to evaluate watermarking...
>
>
> Could someone help me?
>
> Thanks in advance
> --
> Juan Ignacio Sánchez Lara
> Ingeniero Técnico en Informática de Sistemas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

--
Juan Ignacio Sánchez Lara
Ingeniero Técnico en Informática de Sistemas

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

Stéphane Wasserhardt

I don't know where the problem is ...
Maybe it's the sampleModel which is changed during conversion and introduce
problems.
You could try to use RenderingHints to use a choosen SampleModel (or use the
SampleModel returned by
cm.createCompatibleSampleModel(pi.getWidth(),pi.getHeight()) )

-----Message d'origine-----
De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
Envoyé : lundi 23 mai 2005 11:15
À : interest@jai.dev.java.net
Objet : Re: [JAI] RGB to YCC to RGB

I actually store it in RGB, so no more conversion is produced... In
fact you see that the RGB values I read are the same that those I
store... I'm pretty convinced the problem is within the RGB->YCC
process is not the inverse of the YCC-> RGB (at least not the one I've
implemented).

This is the code of those steps:

public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel
cm) {
ParameterBlock pb = new ParameterBlock();
pb.addSource(pi).add(cm);
pi = JAI.create("ColorConvert", pb, null);
return pi;
}

When I want to do an YCC->RGB conversion, cm is the original
ColorModel of the image. For the RGB->YCC, cm is obtained with the
following code:

public static ColorModel getPYCCColorModel() {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
int[] bits = { 8, 8, 8 };
ColorModel cm = new ComponentColorModel(cs, bits, false, false,
Transparency.OPAQUE,
DataBuffer.TYPE_BYTE);
return cm;
}

On 5/23/05, Stéphane Wasserhardt wrote:
> I think you have to make sure you store the RGB image in a raw format
> (without compression) !
>
> -----Message d'origine-----
> De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
> Envoyé : lundi 23 mai 2005 10:53
> À : interest@jai.dev.java.net
> Objet : [JAI] RGB to YCC to RGB
>
>
> Hello,
> I'm working on watermarking, which involves modifying image data on
> the frequency domain after converting it to YCC. My problem is the
> following:
> I get a YCC colorspace image (CS_PYCC), I convert it to its original
> colorspace (RGB), and I store it. The problem is that when I open it
> again and convert it to YCC I get different data. For example, the 4
> first coefficients of the YCC image are 223, 5, 218, 66, which turn to
> 247, 3, 246, 247 in RGB. The issue is that when I try to convert them
> to YCC again I get 205, 4, 202, 66, which is perceptually good enough,
> but not good enough to evaluate watermarking...
>
>
> Could someone help me?
>
> Thanks in advance
> --
> Juan Ignacio Sánchez Lara
> Ingeniero Técnico en Informática de Sistemas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

--
Juan Ignacio Sánchez Lara
Ingeniero Técnico en Informática de Sistemas

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

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

Juan Ignacio Sánchez Lara

This is the function code I think you suggest:

public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel cm) {
ParameterBlock pb = new ParameterBlock();
ImageLayout il = new ImageLayout();
il.setSampleModel(cm.createCompatibleSampleModel(pi.getWidth(),pi.getHeight()));
RenderingHints hints = new
RenderingHints(javax.media.jai.JAI.KEY_IMAGE_LAYOUT, il);
pb.addSource(pi).add(cm);
pi = JAI.create("ColorConvert", pb, hints);
return pi;
}

isn't it?

It doesn't change the results :-(

On 5/23/05, Stéphane Wasserhardt wrote:
> I don't know where the problem is ...
> Maybe it's the sampleModel which is changed during conversion and introduce
> problems.
> You could try to use RenderingHints to use a choosen SampleModel (or use the
> SampleModel returned by
> cm.createCompatibleSampleModel(pi.getWidth(),pi.getHeight()) )
>
> -----Message d'origine-----
> De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
> Envoyé : lundi 23 mai 2005 11:15
> À : interest@jai.dev.java.net
> Objet : Re: [JAI] RGB to YCC to RGB
>
>
> I actually store it in RGB, so no more conversion is produced... In
> fact you see that the RGB values I read are the same that those I
> store... I'm pretty convinced the problem is within the RGB->YCC
> process is not the inverse of the YCC-> RGB (at least not the one I've
> implemented).
>
> This is the code of those steps:
>
> public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel
> cm) {
> ParameterBlock pb = new ParameterBlock();
> pb.addSource(pi).add(cm);
> pi = JAI.create("ColorConvert", pb, null);
> return pi;
> }
>
> When I want to do an YCC->RGB conversion, cm is the original
> ColorModel of the image. For the RGB->YCC, cm is obtained with the
> following code:
>
> public static ColorModel getPYCCColorModel() {
> ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
> int[] bits = { 8, 8, 8 };
> ColorModel cm = new ComponentColorModel(cs, bits, false, false,
> Transparency.OPAQUE,
> DataBuffer.TYPE_BYTE);
> return cm;
> }
>
>
>
>
>
> On 5/23/05, Stéphane Wasserhardt wrote:
> > I think you have to make sure you store the RGB image in a raw format
> > (without compression) !
> >
> > -----Message d'origine-----
> > De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
> > Envoyé : lundi 23 mai 2005 10:53
> > À : interest@jai.dev.java.net
> > Objet : [JAI] RGB to YCC to RGB
> >
> >
> > Hello,
> > I'm working on watermarking, which involves modifying image data on
> > the frequency domain after converting it to YCC. My problem is the
> > following:
> > I get a YCC colorspace image (CS_PYCC), I convert it to its original
> > colorspace (RGB), and I store it. The problem is that when I open it
> > again and convert it to YCC I get different data. For example, the 4
> > first coefficients of the YCC image are 223, 5, 218, 66, which turn to
> > 247, 3, 246, 247 in RGB. The issue is that when I try to convert them
> > to YCC again I get 205, 4, 202, 66, which is perceptually good enough,
> > but not good enough to evaluate watermarking...
> >
> >
> > Could someone help me?
> >
> > Thanks in advance
> > --
> > Juan Ignacio Sánchez Lara
> > Ingeniero Técnico en Informática de Sistemas
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>
>
> --
> Juan Ignacio Sánchez Lara
> Ingeniero Técnico en Informática de Sistemas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

--
Juan Ignacio Sánchez Lara
Ingeniero Técnico en Informática de Sistemas

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

Aastha Bhardwaj

FYI, this behavior was filed as bug 6279846 based on a later test case
provided by Juan. The bug can be viewed at

http://bugs.sun.com/bugdatabase/index.jsp

Aastha

---------------------
Aastha Bhardwaj
Java Advanced Imaging
Sun Microsystems

> This is the function code I think you suggest:
>
> public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel cm) {
> ParameterBlock pb = new ParameterBlock();
> ImageLayout il = new ImageLayout();
> il.setSampleModel(cm.createCompatibleSampleModel(pi.getWidth(),pi.getHeight()));
> RenderingHints hints = new
> RenderingHints(javax.media.jai.JAI.KEY_IMAGE_LAYOUT, il);
> pb.addSource(pi).add(cm);
> pi = JAI.create("ColorConvert", pb, hints);
> return pi;
> }
>
> isn't it?
>
> It doesn't change the results :-(
>
> On 5/23/05, Stéphane Wasserhardt wrote:
>
>>I don't know where the problem is ...
>>Maybe it's the sampleModel which is changed during conversion and introduce
>>problems.
>>You could try to use RenderingHints to use a choosen SampleModel (or use the
>>SampleModel returned by
>>cm.createCompatibleSampleModel(pi.getWidth(),pi.getHeight()) )
>>
>>-----Message d'origine-----
>>De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
>>Envoyé : lundi 23 mai 2005 11:15
>>À : interest@jai.dev.java.net
>>Objet : Re: [JAI] RGB to YCC to RGB
>>
>>
>>I actually store it in RGB, so no more conversion is produced... In
>>fact you see that the RGB values I read are the same that those I
>>store... I'm pretty convinced the problem is within the RGB->YCC
>>process is not the inverse of the YCC-> RGB (at least not the one I've
>>implemented).
>>
>>This is the code of those steps:
>>
>>public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel
>>cm) {
>> ParameterBlock pb = new ParameterBlock();
>> pb.addSource(pi).add(cm);
>> pi = JAI.create("ColorConvert", pb, null);
>> return pi;
>>}
>>
>>When I want to do an YCC->RGB conversion, cm is the original
>>ColorModel of the image. For the RGB->YCC, cm is obtained with the
>>following code:
>>
>>public static ColorModel getPYCCColorModel() {
>> ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
>> int[] bits = { 8, 8, 8 };
>> ColorModel cm = new ComponentColorModel(cs, bits, false, false,
>> Transparency.OPAQUE,
>> DataBuffer.TYPE_BYTE);
>> return cm;
>> }
>>
>>
>>
>>
>>
>>On 5/23/05, Stéphane Wasserhardt wrote:
>>
>>>I think you have to make sure you store the RGB image in a raw format
>>>(without compression) !
>>>
>>>-----Message d'origine-----
>>>De : Juan Ignacio Sánchez Lara [mailto:juanignaciosl@gmail.com]
>>>Envoyé : lundi 23 mai 2005 10:53
>>>À : interest@jai.dev.java.net
>>>Objet : [JAI] RGB to YCC to RGB
>>>
>>>
>>>Hello,
>>>I'm working on watermarking, which involves modifying image data on
>>>the frequency domain after converting it to YCC. My problem is the
>>>following:
>>>I get a YCC colorspace image (CS_PYCC), I convert it to its original
>>>colorspace (RGB), and I store it. The problem is that when I open it
>>>again and convert it to YCC I get different data. For example, the 4
>>>first coefficients of the YCC image are 223, 5, 218, 66, which turn to
>>>247, 3, 246, 247 in RGB. The issue is that when I try to convert them
>>>to YCC again I get 205, 4, 202, 66, which is perceptually good enough,
>>>but not good enough to evaluate watermarking...
>>>
>>>
>>>Could someone help me?
>>>
>>>Thanks in advance
>>>--
>>>Juan Ignacio Sánchez Lara
>>>Ingeniero Técnico en Informática de Sistemas
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>>>For additional commands, e-mail: interest-help@jai.dev.java.net
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>>>For additional commands, e-mail: interest-help@jai.dev.java.net
>>>
>>>
>>
>>
>>--
>>Juan Ignacio Sánchez Lara
>>Ingeniero Técnico en Informática de Sistemas
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>>For additional commands, e-mail: interest-help@jai.dev.java.net
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>>For additional commands, e-mail: interest-help@jai.dev.java.net
>>
>>
>
>
>

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