is it possible to smooth edges using openCV(python). mask.
Asked
Active
Viewed 6,930 times
3
-
1Take a look at this http://stackoverflow.com/questions/7416025/how-do-i-smooth-the-curvescontours-in-opencv Is what you are looking for? – Cezar Sas Dec 24 '16 at 13:24
-
I also found this: http://stackoverflow.com/questions/37068448/opencv-how-to-smooth-contour-reducing-noise – Cezar Sas Dec 24 '16 at 13:26
-
Thanks Cezar. I wanted to understand the steps that are being used in the link. The answer you provided also can help but it is giving a white image right now. – ISha Dec 25 '16 at 09:52
-
Can you provide a sample image? – Cezar Sas Dec 25 '16 at 15:39
-
I have edited the question. – ISha Dec 26 '16 at 13:15
1 Answers
5
Try this code:
import cv2
print(cv2.__version__)
img = cv2.imread('iep43.jpg', 0)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (11, 11))
(thresh, binRed) = cv2.threshold(img, 128, 255, cv2.THRESH_BINARY)
opening = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel, iterations=3)
cv2.imwrite("cleaned.jpg", opening)
It uses the morphological operation of opening

Cezar Sas
- 306
- 3
- 14