Login  Register

Re: subtraction of ROIs

Posted by Jim Cant on Jun 07, 2007; 1:29am
URL: http://imagej.273.s1.nabble.com/subtraction-of-ROIs-tp3699147p3699148.html

I'm curious as to what the goal is; it may make the problem simpler or harder; it appears that the suggestions in this thread have all been retracted.   ;-)

If it's just to visually show the subtracted area (donut) then there's really no need to subtract.
If the area if the donut is needed, just to 'measure' on the roi's subtract the areas.

If the goal is to actually read and/or manipulate the pixels in the donut -- well this seems really hard.
First, it doesn't seem possible to represent the donut as an ROI in ImageJ as it cannot be represented as list of vertices (which, I believe, is the data held internally to represent the ROI; you would need 2 such lists.

If one wanted to write some code, one could do isPixelInDonut() by traversing all the pixels in the bounding rectangle of the outer ROI and asking if the pixel was contained in the outer and not contained in the inner ROI. This would give the correct set of pixels which you would than have to handle individually.

One could draw an approximation of the donut by 1. outlining the inner ROI clockwise but just as you get back to the start, 2. move to a point on the outer ROI and 3. outline it in the counter-clockwise direction and as you get back to the start of the outer, 4. move to the start of the inner.  This will give a conventional ROI that will be a donut with a cut in it.  If you can make the cut small enough, this might be workable.

Again, if you wanted to write some code, you could take the 2 ring ROIs, get the list of vertices from each, and create a 'donut with cut' roi that would include exactly the pixels in the donut.

Hope this helps

<quote author="F Javier Diez Guerra">
How can I make a ROI that is the result of the subtraction between two ROIs?

Searching docs and list archives I've only found
how to make "composite selections", which are
created by hand (by drawing a ROI inside another, while pressing the alt key).

I have two ROIs in the ROI manager, one ROI
inside the other one. I want to select the area
within the bigger ROI, excluding the area of the
smaller ROI. If we were talking of two circles
(one inside the other), I want select the area
defined by the ring between them.