300x250
import cv2
from matplotlib import pyplot as plt
from skimage.filters import try_all_threshold
def main():
gray = cv2.imread("sudoku.jpg", cv2.IMREAD_GRAYSCALE)
threshold = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 19, 2)
threshold2 = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 15, 2)
fig, ax = try_all_threshold(gray, figsize=(10, 8), verbose=False)
plt.show()
return
skimage의 try_all_threshold를 사용해서 7가지 threshold 처리를 동시에 확인할 수 있습니다.
결과는 좋지 않습니다. 추가로 라이브러리 import 필요할 수 있습니다.
adaptiveThreshold의 ADAPTIVE_THRESH_MEAN_C 옵션을 사용한 이미지입니다.
adaptiveThreshold의 ADAPTIVE_THRESH_GAUSSIAN_C 옵션을 사용한 이미지입니다.
300x250
'Image Processing' 카테고리의 다른 글
blur estimation or detection with python 관련 정리 (0) | 2021.04.22 |
---|---|
OPENCV PYTHON RGB 값에서 HSV 값으로 변환 (0) | 2021.02.02 |
Image Flip (Horizontal/Vertical) (0) | 2020.10.14 |
Image Sharpening / Unsharp Image (0) | 2020.10.14 |
Image Brightness and Contrast 변경 (0) | 2020.10.14 |