PDA

Click to See Complete Forum and Search --> : Extracting RGB


Greyskull
Oct 19th, 2007, 06:57 AM
Hello,

I've developing an application which needs to extract RGB for each pixel in an image then later do some calculations with chromaticityu using some formulae.

I can do d calculations but i do not know where to start. I can save an image onto the computer's memory but im stuck as i dnt knw how to extract pixels and RGB...

can anyone help?

Thanks in advance

ComputerJy
Oct 19th, 2007, 08:42 PM
I think the class java.awt.image.BufferedImage is the answer to your problem.
take a look at it, it has a method called "getRGB" that requires x,y in offsets and returns an integer representation for the RGB color in that pixel.

Greyskull
Oct 26th, 2007, 05:16 AM
I've actually found two ways to extract it and save its values to an array.

These two methods are using Raster and using the following:

int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;

where pixel = getPixel(image.getRGB(x,y))

I've used the latter one but I heard that the Raster method is quicker.

Thanks for the advice tho ;)