Re: Convert byteprocessor Stack to RGB stack

Posted by Graeme Ball-2 on
URL: http://imagej.273.s1.nabble.com/Convert-byteprocessor-Stack-to-RGB-stack-tp5004863p5004864.html

Hi Arndt,

I have a plugin that requires this conversion, and something like the
following method should do it:-

import IJ.process.ImageConverter;

/** Convert red, green and blue ByteProcessors to a single ColorProcessor */
ImageProcessor bytes2RGB(ByteProcessor bpRed,
                        ByteProcessor bpGreen,
                        ByteProcessor bpBlue) {
    // assumes all ByteProcessors are the same size...
    ImageStack RGBset = new ImageStack(bpRed.getWidth(), bpRed.getHeight());
    RGBset.addSlice("1", bpRed);
    RGBset.addSlice("2", bpGreen);
    RGBset.addSlice("3", bpBlue);
    ImagePlus tempImp = new ImagePlus("Temp", RGBset);
    ImageConverter ic = new ImageConverter(tempImp);
    ic.convertRGBStackToRGB();
    return tempImp.getStack().getProcessor(1);
}



On Thu, Sep 19, 2013 at 7:08 PM, Arndt Rohwedder <[hidden email]> wrote:

> Hi all
> I'm getting increasingly desperate to convert a stack containing 3 grey
> images generated by ImageProcessor into a RGB image within a Plugin.
>  After separating a RGB images into single channel stacks, doing my
> manipulation, and generting a new stack the resulting Stack cannot
> converted in RGB. The ColorProcessor does not accept the single planes
> because ByteProcessor cannot be used by ColorProcessor (Error message).
> Using .convertToRGB does not have any effect (same message). The single
> images have been build using ImageProcessor and were added to the new
> stack using stack.addslice(imageprocessor).
> Is there anyone out the who might be able to help, please ?
>
> Thanks a lot
> Arndt
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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