【发布时间】:2020-01-17 11:54:28
【问题描述】:
这是我的例子。从左到右:
- 原图
- 灰度 + (3,3) 高斯模糊
- Otsu 阈值处理 + 反转像素
我想捕捉更多笔触的微弱部分。我了解 Otsu Thresholding 尝试在像素强度直方图的两个峰值之间应用阈值点,但我想稍微偏一些,以便捕获一些较亮的像素。
是否可以开箱即用?还是我需要手动操作?
【问题讨论】:
标签: python opencv image-thresholding
这是我的例子。从左到右:
我想捕捉更多笔触的微弱部分。我了解 Otsu Thresholding 尝试在像素强度直方图的两个峰值之间应用阈值点,但我想稍微偏一些,以便捕获一些较亮的像素。
是否可以开箱即用?还是我需要手动操作?
【问题讨论】:
标签: python opencv image-thresholding
【讨论】:
偏置 Otsu 阈值的替代方法是进行基于区域的阈值处理,如下所示:
thr = .8
blur_hor = cv2.filter2D(img[:, :, 0], cv2.CV_32F, kernel=np.ones((11,1,1), np.float32)/11.0, borderType=cv2.BORDER_CONSTANT)
blur_vert = cv2.filter2D(img[:, :, 0], cv2.CV_32F, kernel=np.ones((1,11,1), np.float32)/11.0, borderType=cv2.BORDER_CONSTANT)
output = ((img[:,:,0]<blur_hor*thr) | (img[:,:,0]<blur_vert*thr)).astype(np.uint8)*255
【讨论】:
在 C++ 中,我经常“调出”(otsu)阈值函数返回的阈值,将其乘以一个因子并将其传递回(固定)阈值函数:
//get the threshold computed by otsu:
double otsuThresh = cv::threshold( inputImage, otsuBinary, 0, 255,cv::THRESH_OTSU );
//tune the threshold value:
otsuThresh = 0.5 * otsuThresh;
//threshold the input image with the new value:
cv::threshold( inputImage, binaryFixed, otsuThresh, 255, cv::THRESH_BINARY );
【讨论】: