This post was updated on .
I have a set of point (I have their x,y pixel coordinates) that I would like to add to the ROI manager. how do I do that?
|
Here is a small code snippet:
************************************** ImagePlus imp = IJ.getImage(); /*Create a Polygon ROI!*/ 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); /*Add the ROI to the ROI Manager!*/ RoiManager manager = RoiManager.getInstance(); if (manager == null) { manager = new RoiManager(); } manager.addRoi(polRoi); ************************************* For different ROI types see: http://rsbweb.nih.gov/ij/developer/api/ij/gui/Roi.html |
Hi, So sorry but I'm a newbie... where do I put this code? 2014-08-18 9:55 GMT+03:00 Bio7 [via ImageJ] <[hidden email]>:
Here is a small code snippet: |
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 |
nice! thanks it works :) 2014-08-29 9:57 GMT+03:00 Bio7 [via ImageJ] <[hidden email]>:
Hello, |
Free forum by Nabble | Edit this page |