Posted by
Kenneth Sloan-2 on
Jun 24, 2017; 1:59am
URL: http://imagej.273.s1.nabble.com/ZProjector-can-t-process-RGB-stack-tp5018958.html
Context: Java plugin
I’m currently building a stack containing two RGB images, like so:
ImageStack RGStack = greenIPlus.createEmptyStack();
RGStack.addSlice("Red",redIPlus.getProcessor());
RGStack.addSlice("Green",greenIPlus.getProcessor());
ImagePlus RGIPlus = new ImagePlus("Stack",RGStack);
Here, “red” and “green” refer to the dominant color in each image, but both are RGB images. I suppose I *could* make them single channel and
color them, but I’d prefer “simple”.
If it matters, once this RGStack is built, I’m applying a fairly complicated overlay, which should appear no matter what slice is viewed. That
all works now. I’m just trying to enhance the stack by adding the Projection.
I want to also include a z-projected version, combining the two images. I tried this:
ZProjector zp = new ZProjector(RGIPlus);
zp.setStartSlice(1);
zp.setStopSlice(2);
zp.setMethod(zp.SUM_METHOD);
zp.doProjection();
ImagePlus projectionIPlus = zp.getProjection();;
RGStack.addSlice("Red+Green",projectionIPlus.getProcessor());
But, zp.doProjection() complains that it can only handle non-RGB stacks.
But…when I use the gui - I can select the stack and ask for Image->Stacks->Z Project and it works just fine. It generates
an RGB Color image called “SUM_Stack”.
Recording this gives:
run("Z Project...", "projection=[Sum Slices]”);
selectWindow("Stack”);
I suppose I could use IJ.run("Z Project...", "projection=[Sum Slices]”);
But…I’m unsure how to (in java) refer to the “SUM_Stack” image (so that I can add it to the RGStack - with title “Red+Green”.
So - two part question:
a) is there a way to directly perform the Z Projection (in java) to replicate the SUM_Stack I can generate in the interface?
b) failing that, if I use IJ.run("Z Project...", "projection=[Sum Slices]”); how do I get a handle on the resulting RGB image, so that I can add it
to my 2-element stack (making it a 3-element stack: “red” image, “green” image, Summed image).
Either method will work for me.
[note that the ideal answer would edit my second code fragment above, so it gets the intended (is it obvious?) result.]
Thank you for your time.
As a last resort, I can write a routine to take my two RGB images and create a third projected image. I’ve written that program about 20 times over the past 40 years - but I’m trying real hard to resist the urge to “just do it myself” and learn how to use the standard ImageJ tools. My customer is taking the weekend to write a macro to do the projection (and possibly the insertion into the stack). I’d like to get a fully automated version working first...
--
Kenneth Sloan
[hidden email] <mailto:
[hidden email]>
Vision is the art of seeing what is invisible to others.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html