### How To Make Geodesic Dilation And Erosion In Morphology

Geodesic dilation and erosion are fundamental morphological reconstruction algorithms which yield the same result if left to converge.

Filter by Category

- C# Tutorial(85)
- C# Image Processing(69)
- Morphological Processes(20)
- Image Processing(16)
- Image Restoration and Reconstruction(16)
- Image Segmentation(13)
- C# Data Structures And Algorithms(11)
- Color Image Processing(8)
- Frequency Domain Filtering(8)
- Image Noise(6)
- Grayscale Morphology(5)
- Thresholding(4)
- Order-Statistic Filters(4)
- Mean Filters(4)
- Sorting Algorithms(4)
- Morphological Reconstruction(3)
- Edge Detection(3)
- Simple Lists(2)
- RGB to HSI Color Model(2)
- Adaptive Filters(2)
- Tone and Color Corrections(2)
- Linked Lists(2)
- Stacks(1)
- Queues(1)
- Point Detection(1)
- Line Detection(1)
- C# Arrays(1)
- Region Segmentation Using Superpixels(1)
- Region Segmentation With K Means Clustering(1)
- Region Splitting And Merging(1)
- Sorted Lists(1)
- Region Growing Segmentation(1)
- Digital Image Watermarking(1)
- Using Color In Image Segmentation(1)
- Social Games(1)
- Bandreject Filters(1)
- Bandpass filters(1)
- Notch Filters(1)
- Landing Pages(1)
- Intensity Slicing and Color Coding(1)
- Color Slicing(1)
- Histogram Processing Color Images(1)
- Color Image Smoothing And Sharpening(1)
- C# Basics(1)

How To Make Geodesic Dilation And Erosion In...

Geodesic dilation and erosion are fundamental operations in morphological reconstruction branch. Furthermore, these processes have a special spin on basic dilation and erosion. They enable us reconstruction of specific shapes in the image.

However, we’re still dealing with binary images here. In case you’re new here, binary images are images that hold either black or white pixels. In other words, we can divide these images to two sets, one for foreground pixels and other for background pixels.

The special thing about these two processes is that we use two images for each of them instead of one. Similarly to basic versions, we need an image to apply either dilation or erosion on it. Together with this image, we also need a masking image, which will limit the growth or shrinkage of the resulting image.

With geodesic dilation, we need to acquire the intersection between masking image and dilated image. As we mentioned before, masking image will limit the way successive dilations grow.

On the other hand, geodesic erosion is a morphological dual to dilation. Therefore, both processes will eventually converge to the same result. However, with erosion, we take away foreground pixels, so what we’re looking for is the union between input and masking image.

Both operations converge after a finite number of steps, which yield a resulting image that is identical to the masking image.

One example of geodesic dilation use was in the pruning tutorial post on this blog. We used it to reconstruct a part of handwritten letters, we removed in the thinning process. I recommend you check it out to learn more about the process.

Although I make a demo project for each of the process I describe on this blog, I will only post a segment that applies geodesic dilation on this one. However, it should give you an idea of how to implement the erosion as well.

```
public static byte[] Dilate(this byte[] buffer, byte[] limiter, int w, int h)
{
byte[] result = buffer;
```` for (int x = 1; x < w - 1; x++)`

` {`

` for (int y = 1; y < h - 1; y++)`

` {`

` int position = x + y * w;`

` byte val = 15;`

` for (int kx = -1; kx < 2; kx++)`

` {`

` for (int ky = -1; ky < 2; ky++)`

` {`

` int se_pos = position + kx + ky * w;`

` val = Math.Max(val, buffer[se_pos]);`

` }`

` }`

` if (limiter[position] > 0)`

` {`

` result[position] = val;`

` }`

` }`

` }`

` return result;`

` }`

I hope this post helped you understand how geodesic dilation and erosion in image processing work.

## Comments