Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Scikit图像otsu阈值生成零阈值_Python_Image Processing_Scikit Image_Image Thresholding - Fatal编程技术网

Python Scikit图像otsu阈值生成零阈值

Python Scikit图像otsu阈值生成零阈值,python,image-processing,scikit-image,image-thresholding,Python,Image Processing,Scikit Image,Image Thresholding,我正在对一幅图像进行一些预处理,在应用到图像上之后,我得到了零阈值,而在另一幅图像上,它工作正常 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这是正确的结果。您的图像是双层的,它只有0和255的值,因此0

我正在对一幅图像进行一些预处理,在应用到图像上之后,我得到了零阈值,而在另一幅图像上,它工作正常

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

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

threshold = filters.threshold_otsu(img)
binary = im > threshold
用一些虚拟的“图像”自己试一试:


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

threshold = filters.threshold_otsu(img)
binary = im > threshold
用一些虚拟的“图像”自己试一试:


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