Hello all,
I ran into a problem which I cannot solve on my own and I found not help in the maillist archives. I developed a plugin for version 1.29 back in 2002 which does not work any longer with the current version 1.35. There must be some difference I cannot figure out myself. I want to get the x,y coordinate of the bounding box of a polyline. When I use a polygon it works fine, but not with the polyline. In version 1.29 this approach worked as I expected it. For ease of explanation I add the source of a reduced plugin. I would apreciate any hint which helps me to solve this problem very much. Thank you for your help Sincerely KarlHz /** * 23.2.2006 * This is a test-file only. It does not do anything meaningful. * I prepared it to demonstrate my problem. * * I want to get the x- and y-coordinate of the bounding box of a polyline ROI which I draw into the image * According to my understanding of the documentation there should be no difference between a polyline and a polygon * concerning the calls I use in this example. * * But in all my tests I get the x- and y-coordinate of a polygon ROI correctly. * However, as soon as I replace the polygon with a polyline I get only zeros for the x and y coordinate. * And I cannot find the reason. * * I used the same approach with verion 1.29k and and it worked when I developed this the first time in 2002 and even now the same class file works as I expect it with this version but not in version 1.35q. */ // I did not remove the libraries which are not necessary here because I need them in my real application import ij.IJ; import ij.ImagePlus; import ij.gui.NewImage; import ij.gui.PolygonRoi; import ij.gui.Roi; import ij.plugin.filter.PlugInFilter; import ij.process.ImageProcessor; import ij.util.Tools; import java.awt.Point; import java.awt.Polygon; import java.awt.Rectangle; public class TestRoi_ implements PlugInFilter { static ImagePlus orgImg; public int setup(String arg, ImagePlus imp) { orgImg = imp; return DOES_8G+DOES_32; } // I draw the ROI into the image before this plugin is called // a polyline would be fine because I want to mark a sawline // a polygon will work too but is not so nice public void run(ImageProcessor ip) { Rectangle rectRoi = ip.getRoi(); PolygonRoi polyRoi; polyRoi = (PolygonRoi) orgImg.getRoi(); int roiX = rectRoi.x; int roiY = rectRoi.y; int roiWidth = rectRoi.width; int roiHeight = rectRoi.height; // when I use a polygon everything is as expected and I get the coordinates of the bounding box // when I use a polyline I always get x,y = 0,0 and the width and height of the image orgImg // this works different with version 1.29 - there it is as expected. System.out.println("roiX: " + roiX); System.out.println("roiY: " + roiY); System.out.println("roiWidth: " + roiWidth); System.out.println("roiHeight: " + roiHeight); } void showAbout() { IJ.showMessage("About ...","This PlugIn does ...!"); } } |
Free forum by Nabble | Edit this page |