Login  Register

Re: How to work with color images?

Posted by ctrueden on May 25, 2011; 6:30pm
URL: http://imagej.273.s1.nabble.com/How-to-work-with-color-images-tp3684447p3684448.html

Hi Juan,

So, do I have to convert every pixel like that before working with them? Is
> there no API for RGB images? Maybe a method to split the image in three
> different gray scale images and to merge them after being processed, would
> be helpful.
>

There are many different ways of dealing with it. To split into three
different grayscale images first, use a command such as:

  IJ.run(imp, "Split Channels", "");

(This is what the macro recorder produces when executing the command Image >
Color > Split Channels.)

But just using the bitmasking code you mentioned is fine too.

Regards,
Curtis

On Wed, May 25, 2011 at 5:09 AM, Juanjo Vega <[hidden email]> wrote:

> Hello everyone,
>
> 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
>
> So, do I have to convert every pixel like that before working with them? Is
> there no API for RGB images? Maybe a method to split the image in three
> different gray scale images and to merge them after being processed, would
> be helpful.
>
> Any help will he welcome, plugins, API reference, etc. :)
>
> Sincerely,
>
> Juanjo.
>
> ------------------------------------------------------------
> Juanjo Vega ([hidden email])
>
> Unidad de Biocomputación. Laboratorio B-13.
> Centro Nacional de Biotecnología. CNB-CSIC.
> C\ Darwin, 3. Campus de Cantoblanco.
> Universidad Autónoma de Madrid.
> 28049, Madrid, Spain.
>
> http://www.cnb.csic.es
> http://www.biocomp.cnb.csic.es
>
> +34 91 585 4510
>
> "Las mejores almas son capaces de los mayores vicios como de las mayores
> virtudes, y aquellos que caminan despacio por el camino recto pueden
> llegar más lejos que los que corren pero se apartan de él." - Discurso
> del Método, René Descartes.
>