我正在对一个图像做一些预处理,在图像上应用Otsu阈值之后,我获得了零阈值,而在另一个图像上,它工作得很好
from skimage import filters
from skimage.io import imread
img = imread(img_path, as_gray=True)
threshold = filters.threshold_otsu(img)
print(threshold)
阈值:0

阈值:204
发布于 2019-09-25 07:25:16
这是正确的结果。您的图像是双级别的,它的值只有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))
8https://stackoverflow.com/questions/58092099
复制相似问题