Hello I've been trying to understand the grayscale dilation operation using the following example, but my results are different.
$I = \begin{pmatrix} \bf{5} & 2 & 4 \\ 1 & -3 & 1 \end{pmatrix}$
is the image to be dilated, and the structuring element is
$S = \begin{pmatrix} 0 & x & \bf{0} \\ 0 & 2 & -1 \end{pmatrix}$
I have marked the origin in the structuring element and the image (the bold $\bf5$ in the top left of $I$ and the bold $\bf0$ in the top right of $S$), and $x$ means that the pixel is not part of the structuring element. The correct answer is supposed to be
$\begin{pmatrix} 5 & 2 & 5 & 2 & 4 \\ 5 & 7 & 4 & 6 & 3 \\ 1 & 3 & 1 & 3 & 0 \end{pmatrix}$
but my result is
$\begin{pmatrix} 4 & 7 & 5 & 6 & 4 \\ 5 & 3 & 5 & 3 & 4 \\ 1 & -3 & 1 & -3 & 1 \end{pmatrix}$
What I did was, put the center of the s.e. in each pixel, for each pixel in the neighborhood sum pixel to pixel their values and take the max of the neighborhood as the new value.
For example, when the s.e. is in pixel $I(0,1)$ then
$$ \max( I(0,0)+SE(0,-1), I(0,1)+SE(0,0), I(1,0)+SE(1,-1), I(1,1)+SE(1,0) ) =\\ \max(5+x=x, 2, 3, -4) $$
- Can someone explain to me what is the correct way of doing this?
- In the dilation do we need to flip the structuring element? What about erosion?