Login  Register

Re: How to work with color images?

Posted by Gabriel Landini on May 25, 2011; 10:50am
URL: http://imagej.273.s1.nabble.com/How-to-work-with-color-images-tp3684447p3684450.html

On Wednesday 25 May 2011 11:09:41 you wrote:

> I need to work with colour images in a plugin I'm developing, and as it is
> my first time and I'm pretty confused.
>
> I had a look into the "Color Threshold" plugin and found this:
>
> int c, r, g, b;
> c=ip.getPixel(x,y);
> r = ((c&0xff0000)>>16);//R
> g = ((c&0x00ff00)>>8);//G
> b = ( c&0x0000ff); //B

Yes, the pixel has 3 values packed into an integer value, so you need to
unpack them.

You should read Werner Bailer's tutorial:
http://www.imagingbook.com/fileadmin/goodies/ijtutorial/tutorial171.pdf

Cheers
G.