Posted by
Michael Schmid on
Sep 04, 2014; 7:29pm
URL: http://imagej.273.s1.nabble.com/Alpha-Channel-PlugIn-as-Macro-tp5009498p5009510.html
Hi Marie,
IJ.run without ImagePlus Argument works on the currently active image, which is your "forground".
You paste onto the "background" image, so you want to run the plugin on that image.
You can use the IJ.run command to tell which ImagePlus the command should act on:
IJ.run(ImagePlus imp, String command, String options)
In the current case,
IJ.run(imp2,"Alpha Channel",
"alpha=DUP_forground range=50 enlarge=0 smooth=2.0");
This assumes that there is an image named "DUP_forground" where the alpha (transparency) is given. "DUP_forground" must have the same size as imp2. It must be an 8-bit or 32-bit image.
Michael
________________________________________________________________
On Sep 4, 2014, at 20:05, Marie Rasta wrote:
> Hi Michael,
>
> thank you for the fast reply. I used your PlugIn manually to fuse a Grayscale CT-stack with a PET-stack(where LUT is applied).
> and it really works perfectly.
> I followed your advice and converted the images in RGB and used a duplicate of the PET-stack (converted it to 8bit) to determine the transparency...the following
> error shows up: "No previous filter/paste operation that could be modified by an alpha channel."
>
> Here is the modified code:
>
> public static ImagePlus TransparentOverlay(ImagePlus imp, ImagePlus imp2) {
>
> IJ.selectWindow("background");
> IJ.run("RGB Color");
> IJ.selectWindow("forground");
> IJ.run("RGB Color");
>
> ImagePlus imp1 = new Duplicator().run(imp);
> imp1.show();
> //IJ.setPasteMode("Transparent-white");
>
> for (int i = 1; i <= imp.getStackSize(); i++) {
> ImageWindow win = (ImageWindow) WindowManager
> .getWindow("forground");
> imp = win.getImagePlus();
> imp.setSlice(i);
> imp.setRoi(0, 0, imp.getWidth(), imp.getHeight());
> imp.copy(true);
> //imp.copy();
> win = (ImageWindow) WindowManager.getWindow("background");
> imp2 = win.getImagePlus();
> imp2.setSlice(i);
> imp2.paste();
> IJ.wait(10000);
> IJ.run("Alpha Channel",
> "alpha=DUP_forground range=50 enlarge=0 smooth=2.0");
> imp2.updateImage();
> }
>
> return imp2;
> }
>
> Thanks in advance for any advice
>
> Marie
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html