Login  Register

Re: converting colors

Posted by Jerome Mutterer-3 on May 09, 2014; 9:12am
URL: http://imagej.273.s1.nabble.com/converting-colors-tp5007615p5007654.html

Dear Sharmon, dear Gabriel
you can also do it by inverting the image, then rotating the hue:

run("Invert");
run("HSB Stack");
run("Macro...", "code=v=(v+128)%255 slice");
run("RGB Color");

Sincerely,

Jerome


On 9 May 2014 10:24, Gabriel Landini <[hidden email]> wrote:

> > I have an image that currently has a black background and red foreground.
> > What I want is a white background with a red foreground for easier
> viewing
> > in a presentation.
>
> Cell Profiler has (or had) an interesting "Invert for Printing" script,
> but I
> never used CP.
> Here is an ImageJ macro version of that, which I think does what you want.
> Cheers
>
> Gabriel
>
> //------------------8<---------------------
> // Invert_for_printing
> // Inverts a fluorescent RGB composite so it has white background
> // Heavily colocalised areas might become obscured
> // G. Landini at bham. ac. uk
> // 28 Nov 2009
> setBatchMode(true);
> a="ori";
> run("Duplicate...", "title=ori");
> b="inverted_for_printing";
> run("Duplicate...", "title="+b);
> selectWindow(b);
> run("Set...", "value=255");
> selectWindow(a);
> run("RGB Stack");
> setSlice(1); // just in case
> selectWindow(b);
> run("RGB Stack");
> setSlice(2);
> imageCalculator("Subtract",b,a); //G
> selectWindow(b);
> setSlice(3);
> imageCalculator("Subtract", b,a); //B
> selectWindow(a);
> setSlice(2);
> imageCalculator("Subtract", b,a); //B
> selectWindow(b);
> setSlice(1);
> imageCalculator("Subtract", b,a); //R
> selectWindow(a);
> setSlice(3);
> imageCalculator("Subtract", b,a);//R
> selectWindow(b);
> setSlice(2);
> imageCalculator("Subtract", b,a);//G
> run("RGB Color");
> setBatchMode(false);
> //------------------8<---------------------
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
 12, rue du Général Zimmer
67084 Strasbourg Cedex
T 0367155339
www.ibmp.cnrs.fr

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html