Re: Can't Recover ImagePlus after Stack Rotate
Posted by
kacollins on
URL: http://imagej.273.s1.nabble.com/Can-t-Recover-ImagePlus-after-Stack-Rotate-tp3687248p3687252.html
Hi Wayne,
The plugin under development is now working perfectly for both
Images and Stacks with the 1.44f9 daily build. Thank you for the fix!
Much appreciation!
Cheers,
Karen
On 8/15/2010 8:26 PM, Rasband, Wayne (NIH/NIMH) [E] wrote:
> On Aug 15, 2010, at 3:29 AM, Karen Collins wrote:
>
>
>> Hi Wayne,
>> With 1.44f8, both my TestPlugin and full Astronomy_Tool plugin end
>> up with imp = null after the stackProcessor.rotateLeft() statement as
>> they did with 1.43u. However, Panel_Stack_Window does work with 1.44f8,
>> and I see that it does not work with 1.43u (i.e. logs null for the imp)
>> as expected, given the fix.
>> My TestPlugin is below. If you don't see a problem with the code,
>> would you be able to test it on your end to check if you see the "imp =
>> null" result as I do in 1.44f8? If I pass imp to buildAstroWindow as a
>> parameter, it works properly.
>>
> Hi Karen,
>
> Your code is fine. The problem was with ImageJ and it is fixed in the 1.44f9 daily build. SetStack() no longer triggers the construction of another ImageWindow or StackWindow when switching between one image and two image stacks. A StackWindow can now display a single image with no scrollbar.
>
> Best regards,
>
> -wayne
>
>
>> Best regards,
>> Karen
>>
>> -----------------------------------------------------------------------
>>
>> import ij.IJ;
>> import ij.*;
>> import ij.ImagePlus;
>> import ij.ImageStack;
>> import ij.gui.ImageCanvas;
>> import ij.gui.StackWindow;
>> import ij.plugin.PlugIn;
>> import ij.process.ImageProcessor;
>> import ij.process.StackProcessor;
>>
>> import java.awt.*;
>> import java.awt.Graphics.*;
>>
>>
>>
>> public class TestPlugin implements PlugIn {
>> public void run(String arg) {
>> ImagePlus imp = IJ.getImage();
>> ImageCanvas ic = imp.getCanvas();
>> AstroStackWindow astroWindow = new
>> AstroStackWindow(imp, ic);
>> }
>>
>> class AstroStackWindow extends StackWindow {
>>
>> AstroStackWindow(ImagePlus imp, ImageCanvas ic) {
>>
>> super(imp, ic);
>>
>> buildAstroWindow();
>> }
>>
>> void buildAstroWindow() {
>>
>> ImageProcessor ip = imp.getProcessor();
>> StackProcessor sp = new
>> StackProcessor(imp.getStack(), ip);
>> ImageStack s2 = null;
>> s2 = sp.rotateLeft();
>> imp.setStack(null, s2);
>>
>> if (imp == null)
>> IJ.log("imp = null");
>> else
>> IJ.log("imp = something");
>> }
>> }
>>
>> }
>>
>> On 8/15/2010 1:37 AM, Rasband, Wayne (NIH/NIMH) [E] wrote:
>>
>>> Hi Karen,
>>>
>>> The ImageJ 1.44f8 daily build fixes a bug that caused ImageJ to unnecessarily create a replacement StackWindow when a setStack() call changed both the image size and the stack size. This caused the 'imp' instance variable in the original StackWindow to be set to null. I attached the plugin I used for testing.
>>>
>>> Best regards,
>>>
>>> -wayne
>>>
>>>
>
>