From: Jeff Higgins on
On 5/5/2010 2:01 PM, Czterysta Czwarty wrote:
> On 4 Maj, 04:09, Jeff Higgins<oohigg...(a)yahoo.com> wrote:
>> This is way outside of what I've done with images, but:
>> what happens if you construct a BufferedImage with a ColorModel
>> that has been constructed with a ColorSpace.getInstance(TYPE_YCbCr)
>> and appropriate values for all the other construction parameters?
>
> I wrote this:
>
> ColorSpace cs = ColorSpace.getInstance(ColorSpace.TYPE_YCbCr);
> int[] bits = { 8, 8, 8 };
> ColorModel cm = new ComponentColorModel(cs, bits, false, false,
> Transparency.OPAQUE, DataBuffer.TYPE_BYTE);

I'm hoping to learn with you. I'll rephrase my question.
Have you been able to construct(or load, or convert to) a valid
BufferedImage that uses a ColorSpace of type ColorSpace.TYPE_YCbCr?

If you have, does theBufferedImage's getRGB()methods return an
appropriate conversion, and will you post a short compilable demo?
If you haven't maybe you should, so as to have something to work with.

>
> but I still don't know how to convert pixel colors there and back. I
> need getLuminance() method etc.

I don't think you will find a YCbCr API in the JDK or JAI, I may be
wrong. If not you'll need to write your own. Lew pointed to one link,
there seems to be much info available on the web.

Wikipedia's article on YCbCr seems to me to imply that a YCbCr color
space is mainly useful as a storage or transmission format and that
leads me to wonder why you want a YCbCr API, especially pasted onto
BufferedImage?






From: Jeff Higgins on
On 5/5/2010 9:54 PM, Jeff Higgins wrote:
Oops, I meant to include this link:
<http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/JAITOC.fm.html>

From: John B. Matthews on
In article
<d0172e20-ec8a-4b12-a69f-b736c092c67c(a)k29g2000yqh.googlegroups.com>,
Czterysta Czwarty <czterystaczwarty(a)gmail.com> wrote:

> On 5 Maj, 21:15, Lew <l...(a)lewscanon.com> wrote:
> > Czterysta Czwarty wrote:
> > > but I still don't know how to convert pixel colors there and back. I
> > > need getLuminance() method etc.
> >
> > Do you have one minute?  Because if you have one minute, you'll find
> > that the first hit on
> > <http://www.google.com/search?hl=en&q=ycbcr+Java>
> > is
> > <http://www.f4.fhtw-berlin.de/~barthel/ImageJ/ColorInspector/HTMLHelp/farbraumJava.htm>
> [...]
> I found this, but I want to do this with ColorModel and ColorSpace and
> I don't know how?

I though you would use the the formula mentioned above to implement
the getRed(), getGreen() and getBlue() method in your extension of
ColorModel.

Also, you might like this example suggested by Jeff Higgins:

<http://helpdesk.objects.com.au/java/changing-the-colormodel-of-a-bufferedimage>

in this discussion:

<http://groups.google.com/group/comp.lang.java.help/browse_frm/thread/63c6c2114e6ddc06>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>