ISha
ISha

Reputation: 151

smooth edges of a segmented mask

is it possible to smooth edges using openCV(python). mask.

Upvotes: 3

Views: 8331

Answers (1)

Cezar Sas
Cezar Sas

Reputation: 306

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

Upvotes: 5

Related Questions