Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV erosion and dilation on colour images

Erosion on a binary image decreases the white regions, while dilation increases it. I tried the same on colour images using OpenCV and got similar results. I tried do erode/dilate on binary jpeg images. Due to lossy compression, the image had intensities in [0,5] and [250,255]. The results I found were interesting. Erosion causes the image to search for the smallest value within a structuring element and replace it. Dilation uses the largest value.

In case of colour images,how are colours considered to be smaller or larger? Do they indirectly convert values to gray, see the intensity and then decide which is larger? Or do they use the mean of the three colours? A third possibility is that they erode/dilate separately on all three colours(R,G,B). Which one of these methods is used?

like image 508
Ashwin Avatar asked Apr 21 '17 05:04

Ashwin


People also ask

What are erosion and dilation in OpenCV?

Erosion and Dilation are morphological image processing operations. OpenCV morphological image processing is a procedure for modifying the geometric structure in the image. In morphism, we find the shape and size or structure of an object.

How is erosion and dilation performed in an image?

Dilation adds pixels to the boundaries of objects in an image, while erosion removes pixels on object boundaries. The number of pixels added or removed from the objects in an image depends on the size and shape of the structuring element used to process the image.

Which OpenCV function is used for erosion?

cv2. erode() method is used to perform erosion on the image. The basic idea of erosion is just like soil erosion only, it erodes away the boundaries of foreground object (Always try to keep foreground in white).

What is image dilation in OpenCV?

Dilation is usually performed after the image is eroded using another morphological transformation operator called Erosion. This process helps in removing the white noise from the image. We can dilate an image in OpenCV using the cv2.


1 Answers

These morphological operations are uneasy to define for color images as colors convey a vector information (three components) and cannot be compared as smaller/larger.

The common implementations just treat the color planes independently. This has the disadvantage of having no good mathematical justification and introduces colors that aren't present in the original image.

Another option is possible, but nowhere in use, it seems: if you choose one arbitrary color, you can dilate/erode by choosing the color of the pixel which is closest/farthest from the chosen one, in the neighborhoods considered.

like image 110
Yves Daoust Avatar answered Sep 28 '22 02:09

Yves Daoust