接著上一篇OpenCV圖像處理基礎1繼續說。
圖像閾值處理
1、簡單閾值處理
ret, thresholded_image = cv2.threshold(image, thresh, maxval, cv2.THRESH_BINARY)
thresh 是閾值,maxval 是最大值。
2、自適應閾值處理
thresholded_image = cv2.adaptiveThreshold(image, maxval, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, block_size, C)
3、Otsu’s 二值化
ret, thresholded_image = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
圖像平滑處理
1、均值濾波
blurred_image = cv2.blur(image, (kernel_size, kernel_size))
2、高斯濾波
blurred_image = cv2