Possible bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug

cihat eldeniz
Dear all,

I believe there is a bug in the two functions of ImageProcessor: erode()
and dilate().

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?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug

Michael Schmid
Hi Cihat,

it depends on the Process>Binary>Options what you define as a  
foreground object and what as a background.

Dilating the background erodes the foreground objects, and vice versa.

Michael
________________________________________________________________

On 16 Feb 2009, at 04:39, Cihat Eldeniz wrote:

> Dear all,
>
> I believe there is a bug in the two functions of ImageProcessor:  
> erode() and dilate().
>
> 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?
>
> Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug

Wayne Rasband
In reply to this post by cihat eldeniz
On Feb 15, 2009, at 10:39 PM, Cihat Eldeniz wrote:

> Dear all,
>
> I believe there is a bug in the two functions of ImageProcessor:  
> erode() and dilate().
>
> 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?

These methods appear to assume that the background is white. The  
Process>Binary>Erode and Process>Binary>Dilate commands assume black  
background if "Black Background" is checked in the  
Process>Binary>Options dialog box.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug

Gabriel Landini
In reply to this post by cihat eldeniz
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