【问题标题】:Scikit image otsu thresholding producing zero thresholdScikit 图像 otsu 阈值处理产生零阈值
【发布时间】:2020-01-25 06:35:13
【问题描述】:

我正在对图像进行一些预处理,在图像上应用Otsu thresholding 后,我的阈值为零,而在另一个图像上它工作正常

from skimage import filters
from skimage.io import imread

img = imread(img_path, as_gray=True)

threshold = filters.threshold_otsu(img)
print(threshold)

H-S-1-G-01.tif

阈值:0

original_1_1.png

阈值:204

【问题讨论】:

  • 你有什么问题?
  • @BogdanDoicin 为什么第一张图片的阈值为零而不是第二张图片

标签: python image-processing scikit-image image-thresholding


【解决方案1】:

这是正确的结果。您的图像是双层的,它只有 0 和 255 的值,所以 0 是一个阈值,当您执行下一步时,它将正确地将图像分成两个值:

threshold = filters.threshold_otsu(img)
binary = im > threshold

用一些虚拟的“图像”自己尝试一下:

filters.threshold_otsu(np.array([0,255],dtype=np.uint8))
0

filters.threshold_otsu(np.array([7,12],dtype=np.uint8)) 
7

filters.threshold_otsu(np.array([7,8,11,12],dtype=np.uint8))
8

【讨论】:

    猜你喜欢
    • 2022-06-22
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-01
    • 1970-01-01
    • 2013-03-11
    • 1970-01-01
    相关资源
    最近更新 更多