On Monday 06 July 2009 11:46:03 Jan Eglinger wrote:
> is there an easy way to determine if two ROIs (or objects represented by
> masks) touch each other?
> My idea was to combine to two masks (binary OR) and then look if the
> resulting mask has one single particle
Yes, that is the best way and the easiest too.
But that will not tell you if the masks are touching each other. If they do,
they are already a single binary object, unless they are in different images.
If they are on the same image and separated by 1 pixel thick background lines
(4-connected), you need to isolate the 2 objects (binary reconstruction is the
way of doing this) then dilate one of the objects twice and look for the
overlap with the other object, or dilate both objects once and look for the
overlap.
If they are in separate images and there is no backgraound pixel between them,
then you need only to dilate one of them once and test for an overlap.
Dave Randell presented on these problems concerning spatial reasoning at the
last ImageJ conference: Discrete Mereotopology in automated histological image
analysis.
http://imagejconf.tudor.lu/archive/imagej-user-and-developer-conference-2008/copy_of_programme/presentations/discrete-mereotopology-in-
automated-histological-image-analysis
Not sure where is the link to the full paper.
By doing the tests with masks, you are guaranteed to be processing the objects
that you see *exactly* (as opposed to operating with ROIs).
As following from a recent thread, the drawn and filled ROI do not correspond
to the same object. So you cannot be sure what pixels you are including with a
ROI unless they are drawn or filled.
Furthermore if you fill a ROI and then draw the outline (or vice versa),
sometimes there will be pixels left unfilled between the filled part and the
drawn outline!. So it is not easy to know what is inside or outside an ROI.
Moreover, these missed points would be filled if the ROI was from a wand
applied to a binary object.
The missed pixels would also be filled if one uses the binary fill holes on
the drawn boundary of the ROI (but the right and bottom borders of ROIs
[except rectangular ones!] are outside the yellow frame).
To me, this is all too complicated and so I try to resolve these problems
using morphological and logical operations rather than ROIs.
I hope it helps.
Gabriel