Login  Register

Re: converting colors

Posted by Gabriel Landini on May 09, 2014; 8:24am
URL: http://imagej.273.s1.nabble.com/converting-colors-tp5007615p5007653.html

> 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