Skip to main content

Convert to Luv colorspace

2 replies [Last post]
jdallas
Offline
Joined: 2007-10-08

Hey folks,
I'm making a small image processing program for kicks. The algorithm requires that all pixel values be in the Luv colorspace. I have looked everywhere in the API and online and can find no way to convert an image to the TYPE_Luv colorspace. I've tried every method that I know of but I still cant find a way to get pixel values reported in the Luv colorspace. If anyone could point me in the right direction it would greatly be appreciated.

P.S. when I do
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorConvertOp op = new ColorConvertOp(cs,null);
buff_Img = op.filter(buff_Img,null);
buff_Img_Raster = buff_Img.getRaster();
and then output
buff_Img_Raster.numbands();
I get the raster has 1 band, whats up with that ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dbecker
Offline
Joined: 2004-05-21

Well, it bugged me enough to write something:

http://java.pastebin.ca/740147

I used the D50 white point since that's what ColorSpace says it uses.

Derek

dbecker
Offline
Joined: 2004-05-21

By default Java (AFAIK) doesn't come with an LUV colorspace. In fact, as far as I can tell it only comes with sRGB. I would love for someone here to tell me I'm wrong, but if you want LUV, HSV, etc you'll have to roll your own. There is some code here:

http://rsb.info.nih.gov/ij/plugins/color-converters.html

That includes conversions to Lab, LUV and HSV. Now that the JDK is open maybe we'll be able to add some more to the default class libs.

Derek