728x90
목표
- 임계값
- cv.threshold기능 배우기
소스
import numpy as np
import cv2 as cv
img = cv.imread("threshold.png", 0)
res, thresh1 = cv.threshold(img, 127, 255, cv.THRESH_BINARY)
res, thresh2 = cv.threshold(img, 127, 255, cv.THRESH_BINARY_INV)
res, thresh3 = cv.threshold(img, 127, 255, cv.THRESH_TRUNC)
res, thresh4 = cv.threshold(img, 127, 255, cv.THRESH_TOZERO)
res, thresh5 = cv.threshold(img, 127, 255, cv.THRESH_TOZERO_INV)
titles = ['Original Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV']
images = [img, thresh1, thresh2, thresh3, thresh4, thresh5]
for i in range(6):
cv.imshow(titles[i], images[i])
cv.waitKey(0)
cv.destroyAllWindows()
'언어 > OpenCV(Python)' 카테고리의 다른 글
[OpenCV]Smoothing 이미지(1) (0) | 2022.03.31 |
---|---|
[OpenCV]이미지 Adaptive Thresholding (0) | 2022.03.28 |
[OpenCV]이미지의 기하학적 변환(2) (0) | 2022.03.25 |
이미지의 기하학적 변환(1) (0) | 2022.03.24 |
[OpenCV]색공간 변경 (0) | 2022.03.23 |