Posted by
Jeremy Adler on
Jul 10, 2015; 5:29am
URL: http://imagej.273.s1.nabble.com/How-can-I-select-ROIs-within-a-ROI-tp5013496p5013497.html
Instead of working with ROIs it might be easier to work with images
you have primary large ROIs, use them to fill a blank image with a different color for each ROI - use the ROI's ID as the intensity used for the fill operation. You now have a segmented image where each ROI is represented by the pixels of a single intensity, with each ROI having a unique intensity based on its ID
create a second blank image and repeat the fill process with the smaller (secondary) ROIs, again using the ROI ID as the fill color.
Now you combine the two images using the Image Correlator plugin - producing an image that shows which primary and secondary ROIs overlap - to check for overlap you just read the pixel value at a xy coordinate based on the IDs of the primary and secondary ROI. a non zero value shows overlap and the number itself is the number of pixels that overlap
This assumes the that the primary ROIs do not overlap each other and similarly that the secondary ROIs do not overlap. I suspect that the image correlator plugin is limited to 8 bit images, so this approach would be limited to 255 primary and 255 secondary ROIs
A lot depends on the questions you want to answer - you may be able to work with images and not ROIs. If your secondary ROIs are used, or even originate, from a binary image you could use this binary image and the segmented primary ROI image to select all the objects within each primary ROI and then use this image to generate a new ROI of all the parts of the secondary ROIs within the each primary ROI and then used analyze\particles etc to make the measurements you want.
________________________________________
From: ImageJ Interest Group [
[hidden email]] on behalf of Avital Steinberg [
[hidden email]]
Sent: 10 July 2015 06:04
To:
[hidden email]
Subject: How can I select ROIs within a ROI?
Hi,
I am writing a macro which segments ROIA, and then segments things within
ROIA - I'll call them ROIA1, ROIA2. Likewise, I have a large ROIB and
within it, some small ROIs - ROIB1, ROIB2, ROIB3, etc. (there may be 400
large ROIs containing smaller ROIs within them)
I would like to be able to select all of the ROIs which are contained
within a certain ROI. How would I do that?
In Java, I would use a tree data structure for this type of search.
How would I do this in a macro? Searching the whole ROI list every time I
want to find a subset is time consuming.
Thanks,
Avital
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html