Fwd: Re: Erode/Dilate

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

Fwd: Re: Erode/Dilate

Peter Haub
Late answer .. maybe it still helps.

Here is an easy version of a DILATE function with a configurable 3x3
structuring element (hot spot in center).
(It is a modified version of a sample code which is available in origin
as part of the book "Digital Image Processing - An Algorithmic
Introduction using Java by Wilhelm Burger and Mark J. Burge)

To use the filter copy the files Dilate_SE.java and Dilate_SE.class into
the \plugins folder.

The Dilate_SE filter can be used from the PlugIns menu.
The structuring element can be changed in the java code. After changing
the element the plugin has to be recompiled with the "Plugins/Compile
and Run .." function.

The Dilate_SE filter can also be used inside a macro with the macro code:
run("Dilate SE", "000110000");
In the macro function the 3x3 structuring element will be passed as a
string with exactly 9 elements (0 or 1).

The logic of the structuring element string is
A  B  C
D  E  F   = ABCDEFGHI
G  H  I

A horizontal dilation can be defined as
0  0  0
1  1  0  = 000110000
0  0  0

A vertical dilation can be defined as
0  1  0
0  1  0  = 010010000
0  0  0

A diagonal dilation can be defined as
1  0  0
0  1  0  = 100010000
0  0  0


The ERODE function can be derived from the DILATE function by inverting
the image before and after dilation.
In the macro code you can use, for example:
run("Invert");
run("Dilate SE", "000110000");
run("Invert");

best regards,
peter


Am 17.02.2011 18:56, schrieb Alfred Wagner:

>  Hello ImageJ Users,
>
>  Is there any way to dilate or erode a binary image in one axis/direction
>  only, rather than symmetrically around the objects?
>  The binary images I'm using are primarily shapes with 90 or 180 degree
>  corners, i.e. not many rounded shapes.
>
>  I've considered shifting  duplicate images along one axis and ORing with
>  the original image, but the run time starts to get very long when
>  processing large numbers of images.
>
>  Any suggestions would be much appreciated.
>
>  Thanks.
>
>  Al Wagner
>  IBM Watson Research Center
>


Dilate_SE.java (2K) Download Attachment