Login  Register

Re: add a set of point coordinates to ROI manager

Posted by adiro on Aug 30, 2014; 10:13am
URL: http://imagej.273.s1.nabble.com/add-a-set-of-point-coordinates-to-ROI-manager-tp5009232p5009423.html

nice! thanks it works :)


2014-08-29 9:57 GMT+03:00 Bio7 [via ImageJ] <[hidden email]>:
Hello,

1. Start ImageJ and create a new Java Plugin: Plugins->New->Plugin
2. Paste the code below in the ImageJ editor (overwrite the default code)
3. Save the file in the ImageJ plugins directory
4. Open an example image
5. Compile and run the plugin from the text editor: File->Compile and Run


import ij.IJ;
import ij.ImagePlus;
import ij.gui.PolygonRoi;
import ij.gui.Roi;
import ij.plugin.PlugIn;
import ij.plugin.frame.RoiManager;

public class My_Plugin implements PlugIn {

        public void run(String arg) {
                ImagePlus imp = IJ.getImage();
                int[] xp = { 5, 50, 100, 150, 200, 250, 300 };
                int[] yp = { 100, 200, 200, 200, 200, 100 };
                PolygonRoi polRoi = new PolygonRoi(xp, yp, 6, Roi.POLYGON);
                imp.setRoi(polRoi);

                RoiManager manager = RoiManager.getInstance();
                if (manager == null){
                        manager = new RoiManager();
                }
                manager.addRoi(polRoi);

        }

}


Read the ImageJ documentation for more details about plugins:

http://imagej.nih.gov/ij/docs/guide/146-16.html#toc-Section-16




If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/add-a-set-of-point-coordinates-to-ROI-manager-tp5009232p5009412.html
To unsubscribe from add a set of point coordinates to ROI manager, click here.
NAML