Dilation and erosion in Android
14,078
Solution 1
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)));
Solution 2
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.
Author by
Hua Er Lim
Updated on August 04, 2022Comments
-
Hua Er Lim over 1 year
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.-
CTZStef over 11 yearsI don't know anything about OpenCV on Android, but I know that smoothing has nothing to do with morphological operations such as dilation and erosion. You will probably have first to obtain your binary image using cvTresh though (or the equivalent on Android).
-
Hua Er Lim over 11 yearsCTZStef,can i know how to use cvTresh to obtain the binary image?Before this,i use my own method to obtain the binary image and the effect is not good.
-
CTZStef over 11 yearsI guess you will find everything you need (e.g. documentation) here : code.opencv.org/projects/opencv/wiki/OpenCV4Android
-
-
Hua Er Lim over 11 yearsremi,i think you are right,i want to use dilation followed by erosion.Because i am new to android,can you give an example on how to code it for android?Thanks.
-
Hua Er Lim over 11 yearsremi,and can you tell me how to control wan erode the white or block parts?Thanks in advanced.
-
remi over 11 yearserode the black = dilate the white. You have to do a simple test, you cannot change that, I dont remember what is decided in OpenCV implementation. As for Android samples, I only use C++/python bindings, but it should be straightforward, shouldn't it?