Re: Iterator over Roi points anywhere

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Iterator over Roi points anywhere

Joost Willemse
You can use the getRoisAsArray to get the wanted ROI from the roi manager,

by then using the getBounds you can get the bounding rectangle and then you
can iterate over the pixels within the ROIs by using the contains method of
the ROI.

See this example:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class RoiIt extends RoiManager implements PlugIn {
static final long serialVersionUID=44L;
RoiManager rm = RoiManager.getInstance();
ImagePlus imp = IJ.openImage("");

public void run(String arg) {;
IJ.setAutoThreshold(imp, "Default");
Prefs.blackBackground = true;, "Convert to Mask", "");, "Analyze Particles...", "size=200-1000000 circularity=0.00-1.00
show=Nothing exclude add");, "RGB Color", "");
Roi[] arrroi=rm.getRoisAsArray();
for (int k=0;k<arrroi.length;k++){
Roi thisroi=arrroi[k];
Rectangle thisBound = thisroi.getBounds();
IJ.setForegroundColor(255, 0, 0);
for (int
for (int
if (thisroi.contains(i,j)){, "Specify...", "width=1 height=1 x="+i +" y="+j);, "Fill", "slice");

ImageJ mailing list: