Re: Possible bug
Posted by Gabriel Landini on Feb 17, 2009; 10:59am
URL: http://imagej.273.s1.nabble.com/Possible-bug-tp3693696p3693697.html
On Monday 16 February 2009 03:39:07 Cihat Eldeniz wrote:
> When I went through a stack of images [that had already been converted
> to binary],
>
> ImageProcessor ip2 = imp2.getStack().getProcessor(counter);
> ip.dilate();
> ip.dilate();
> ..
> I realized that dilate() erodes and erode() dilates. Is there really a bug?
Apart from the previous explanations about image polarity (i.e. what is
background and what is foreground), it is important to be aware that the
erosion implementation of ImageJ is not exactly the dual of dilation.
ImageJ erodes the borders of the image. Many other imaging programs do this
(Optimas comes to mind), but be aware that one runs into some problems if this
is not taken into consideration. For example objects touching the screen
border, do not so anymore after a 'closing' operation, so if one wants to
remove them, one will have a hard time finding out which ones they were.
To perform the exact or traditional erosion in IJ, one has to execute :
invert
dilate
invert
And also this needs to be included in the 'closing' operation (which is
'dilation' followed by 'erosion'), so to do an 'exact closing' it becomes:
dilate
invert
dilate
invert
The 'opening' operation (erosion followed by dilation) does not suffer from
this problem as the final dilation near the border will reconstitute the
eroded border pixels.
Cheers,
Gabriel