# Computations in Grayscale morphology dilation

I red this link, but unfortunately i still don't understand the process...

By the way, Dilation process is performed by laying the structuring element H on the image I and sliding it across the image in a manner similar to convolution.

The grayscale morphological dilation formula is written as follows :

$[I ⊕ H](u,v) = \displaystyle\max_{(i,j)∈H}\{I(u-i,v-j)+H(i,j)\}$

If we assume a greyscale image I of size 2x3, such that I=[1 2 3; 3 7 2]; and a structuring element H of size 1x4, such that H= [0 0 7 7].

What are u,v and i,j? Please can someone explain to me in details how the formula is computed at each element of I in order to obtain the new image dilated_I ? Because i still don't understand well the concept..

What was meant by a structuring element that contains only the origin ? i didn't understand well the concept behind grayscale dilation. Any help will be very appreciated.

Structuring element is mostly supposed to be a binary array (though you can try 0 0 7 7 by yourself). H=[0 0 1 1] u, v are the pixel coordinate at I. In your example, the only pixel value that will change is I(1,2) (the array label starts from 0 instead of 1).

I =  1     2     3
3     7     2


Consider I(1,2), from the formula, I(1,2) I(1,1), and I(1,0) will be considered.

I(1,2) = max( I(1-0,2-0) + H(0,0), I(1-0,2-1) + H(0,1), ...
I(1-0,2-2) + H(0,2), )
= 7


That's the pixel value at (1,2) after dilation.

I will show you I(1,1):

I(1,1)=max(I(1-0,1-0)+H(0,0), I(1,0,1-1)+H(0,1))


That is still the original I(1,1).

EDIT

Mathematically, SE can has any values in its elements, but in Matlab, imdilate only accepts binary SE as a mask to determine the dilation region. You can still use [0 0 7 7] in your own calculation of dilation.

As your suggestion, I am showing you an example with SE of 3X3 size. I will calculate I(2,2).

I =  1     2     3
3     7     2
3     7     2
H =  1     0     0
0     1     1
1     0     1

I(2,2) = max( I(2-0,2-0) + H(0,0), I(2-0,2-1) + H(0,1), I(2-0,2-2) + H(0,2),...
I(2-1,2-0) + H(1,0), I(2-1,2-1) + H(1,1), I(2-1,2-2) + H(1,2),...
I(2-2,2-0) + H(2,0), I(2-2,2-1) + H(2,1), I(2-2,2-2) + H(2,2))
= 7

• why? the structuring element must always be a binary form ? why only I(1,2) is changed ? Dec 28, 2013 at 21:56
• SE is just a mask, within which the bright element (large value) will be enhanced, some dark will be removed. You can check yourself with other elements in I with my method. Other elements are already the maximum within the mask. Dec 28, 2013 at 22:00
• So i can apply your method by using the SE as [0 0 7 7 ] instead of [ 0 0 1 1 ]? and why only I(1,2) is changed, i don't understand why. please i need your help Dec 28, 2013 at 22:03
• see my update in answer. you can do the same thing yourself on other pixels in I Dec 28, 2013 at 22:08
• Thank you very much. Before to accept your answer, I still have one question. I am using a grayscale image, so the SE can be also grayscale true ? so i can use the SE as [0 0 7 7] true ? Dec 28, 2013 at 22:10

If you know the median filter principle, that's exactly the same type of operation.

For each pixel, you take a look to all the neighbor pixels (defined by the structuring element), and you take the max (dilation) or the min (erosion). Therefore it's like the median filter, but instead of taking the median value, you take the min/max.

The mathematical formulae is here, page 3.