<침식>
객체 영역을 깎아 냄 -> 축소
아래 이미지 구현
cv2.ERODE(IMG,KERNEL,ITERATIONS =1) 적용 후, 결과 확인
parameter
- img : Erosion을 수행할 원본 이미지
- kernel : Erosion을 위한 Kernel
- iterations : Erosion 반복 횟수
erode1_rect = cv2.erode(img, kernel, iterations = 1)
erode1_cross = cv2.erode(img, kernel_cross, iterations = 1)
erode2_rect = cv2.erode(img, kernel, iterations = 2)
plt.figure(figsize=(14,5))
plt.style.use('grayscale')
ax1 = plt.subplot(141)
ax2 = plt.subplot(142)
ax3 = plt.subplot(143)
ax4 = plt.subplot(144)
ax1.axis('off')
ax2.axis('off')
ax3.axis('off')
ax4.axis('off')
ax1.imshow(img)
ax2.imshow(erode1_rect)
ax3.imshow(erode1_cross)
ax4.imshow(erode2_rect)
plt.show()
<팽창>
객체 영역을 덧붙임 -> 확대
cv2.DILATE(IMG,KERNEL,ITERATIONS=1) 적용 후 결과 확인
parameter
img = Dilation 수행할 원본 이미지
kernel = Dilation 위한 Kernel
iterations = Dilation 반복 횟수
dilate1_rect = cv2.dilate(img, kernel, iterations = 1)
dilate1_cross = cv2.dilate(img, kernel_cross, iterations = 1)
dilate2 = cv2.dilate(img, kernel, iterations = 2)
plt.figure(figsize=(14,5))
plt.style.use('grayscale')
ax1 = plt.subplot(141)
ax2 = plt.subplot(142)
ax3 = plt.subplot(143)
ax4 = plt.subplot(144)
ax1.axis('off')
ax2.axis('off')
ax3.axis('off')
ax4.axis('off')
ax1.imshow(img)
ax2.imshow(dilate1_rect)
ax3.imshow(dilate1_cross)
ax4.imshow(dilate2)
plt.show()
'OpenCV' 카테고리의 다른 글
OpenCV - 모폴로지 종합 실습 (0) | 2022.11.12 |
---|---|
OpenCV Open(오픈), Close , 기타 모폴리지 연산 (0) | 2022.11.12 |
OpenCV - 모폴로지 연산 (0) | 2022.11.12 |
OpenCV - 소벨 필터 적용 (0) | 2022.11.12 |
OpenCV - Compare (0) | 2022.11.07 |