gpt4 book ai didi

python - 我可以在 OpenCV 中为 Otsu 阈值添加偏差吗?

转载 作者:行者123 更新时间:2023-12-02 16:13:38 26 4
gpt4 key购买 nike

这是我的例子。从左到右:

  1. 原始图片
  2. 灰度 + (3,3) 高斯模糊
  3. Otsu 阈值化 + 反转像素

enter image description here

我想捕捉更多笔划的微弱部分。我知道 Otsu Thresholding 尝试在像素强度直方图的两个峰值之间应用阈值点,但我想稍微调整一下,以便捕获一些较亮的像素。

是否可以开箱即用?还是我需要手动操作?

最佳答案

我有一个橡皮鸭现象的答案。

th, th_img = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)

返回元组的第 0 个索引 (th) 是 Otsu Binarization 算法选择的阈值。我可以丢弃 th_img 并在将其用于常规二进制阈值处理之前将我喜欢的任何偏差应用于 th

desired_th = th*1.2
_, th_img = cv2.threshold(blur, desired_th, 255, cv2.THRESH_BINARY)

这是我得到的。通过清理可能出现在外部的不需要的 Blob ,我会得到我想要的东西。

enter image description here

关于python - 我可以在 OpenCV 中为 Otsu 阈值添加偏差吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59773835/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com