Re: need help, I'm frustrated
Posted by dscho on Jul 16, 2008; 1:13am
URL: http://imagej.273.s1.nabble.com/need-help-I-m-frustrated-tp3695559p3695561.html
Hi,
On Tue, 15 Jul 2008, Hao Jiang wrote:
>
> for(Iterator it = pointsList.iterator(); it.hasNext();){
> ShapeRoi roi = new ShapeRoi((OvalRoi)it.next());
> IJ.getImage().setRoi(roi);
This will set a new roi with every iteration. That is the reason why it
does not work.
You need to use the or() method of ShapeRoi to extend the first, and only
in the end, i.e. _after_ the loop, set the ROI. IOW:
ShapeRoi roi = null;
Iterator it = pointsList.iterator();
while (it.hasNext()) {
ShapeRoi oval = new ShapeRoi((OvalRoi)it.next());
roi = roi == null ? oval : roi.or(oval);
}
IJ.getImage().setRoi(roi);
Of course, you can do that already in the first for() loop. But you get
the idea.
Hth,
Dscho