Re: Create composite rgb image from 2 ImagePlus objects

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/Create-composite-rgb-image-from-2-ImagePlus-objects-tp3695334p3695338.html

> I am writing an imagej plugin that does the following:
>
> 1. Loads an image that has been acquired with a 'dual-view' , i.e. the
> image is grayscale and split down the middle,where one half represents
> one color and the other corresponds to a different color.
> 2. Using ROIs, splits the image into two separate ImagePlus objects of
> equal size (both equal to 1/2 the size of the original)
> 3. Combines the two resultant images into an RGB or composite image
> with the two colors represented by separate channels
>
>
> The problem is with this last step. I can use the RGBMerge plugin from
> the menu, or put the two images into a stack and make an RGB from
> that, but all this is done from the menus. How can I implement this
> programmatically? Again, the end result should be a composite image,
> w/ channels whose balance,level,contrast,brightness,etc can be
> adjusted separately.

The easiest way to do this is to create a stack and use

      IJ.run(imp, "Make Composite", "display=Composite");

where 'imp' is an ImagePlus containing the stack. This method requires
ImageJ 1.41 or later. Or you can create a composite image from a stack
and display it using

     ImagePlus imp2 = new CompositeImage(imp, CompositeImage.COMPOSITE);
     imp2.show();

-wayne