Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dilation and erosion in Android

According to my research,dilation and erosion can be used to bridge the gap for a image after binarize the image.

I not sure if cvSmooth needs to be used or not.

like image 201
Hua Er Lim Avatar asked Sep 15 '12 08:09

Hua Er Lim


People also ask

What is dilation and erosion?

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.

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.

What is erosion in image processing?

Erosion removes pixels on object boundaries. In other words, it shrinks the foreground objects. Enlarge foreground holes. Like in Image Processing Kernels, a larger size of the Structure Element, the effect of Erosion increase.


2 Answers

Android has mostly the same functions has the documented C++/Python, so all you need to do is find which class they belong to, in this case, Imgproc:

Imgproc.erode(mInput, mInput, Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2,2)));        

Imgproc.dilate(mInput, mInput, Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2, 2)));
like image 181
Rui Marques Avatar answered Nov 15 '22 22:11

Rui Marques


You do have erosion and dilation in OpenCV. What you are looking for to "brige the gap" is probably what is called a closure, i.e. a dilatation followed by an erosion. It can be done using a single call to morphologyEx function. It could be an "opening", depending if you want to erode the white or black parts.

like image 39
remi Avatar answered Nov 15 '22 21:11

remi