Different behavior of plugin called from macro

Posted by Jon Harman-3 on
URL: http://imagej.273.s1.nabble.com/Different-behavior-of-plugin-called-from-macro-tp5014701.html

Hi,
I have a plugin that as part of a long sequence of image manipulations
crops an image.  This works fine when run from the plugins menu.  When I
run the plugin from a macro the crop fails, saying an area selection is
required.  When it fails it displays the image with a rectangle ROI
which is the wrong size.
The plugin is then permanently broken until I restart ImageJ.  Then it
works fine again.

This is a mystery to me.  Hope someone can help.  my code is:

Polygon corners = new Polygon();
for(int i = 0; i < 4; i++) corners.addPoint(cor[i].x,cor[i].y);
        corners.addPoint(cor[0].x, cor[0].y);// close the polygon
PolygonRoi corroi = new PolygonRoi(corners, Roi.POLYGON);
                       
iw = trans.getWindow();
iw.toFront();
trans.setRoi(corroi);
trans.show();
IJ.run("Crop");

Jon

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