OpenCV

opening, closing

728x90
import cv2

imageName = 'data/images/opening.png'
image = cv2.imread(imageName,0)

cv2.imshow('original',image)

openingSize = 3

element = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,
                                    (2*openingSize+1, 2*openingSize+1))

imageOpend = cv2.morphologyEx(image, cv2.MORPH_OPEN, element, iterations=3)

cv2.imshow('opend', imageOpend)

cv2.waitKey(0)
cv2.destroyALLWindow()

import cv2

imageName = 'data/images/closing.png'
image = cv2.imread(imageName,0)

cv2.imshow('original',image)

openingSize = 4

element = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,
                                    (2*openingSize+1, 2*openingSize+1))

imageOpend = cv2.morphologyEx(image, cv2.MORPH_CLOSE, element, iterations=3)

cv2.imshow('closed', imageOpend)

cv2.waitKey(0)
cv2.destroyALLWindow()

728x90

'OpenCV' 카테고리의 다른 글

homography_book  (0) 2021.04.20
rotate / warpAffine/ getAffine 이미지 돌리기  (0) 2021.04.20
erode 이미지 침식  (0) 2021.04.20
dilate 이미지 확장  (0) 2021.04.20
Threshold 흐린걸 진하게  (0) 2021.04.20