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 图像阈值化不适用于拉普拉斯图像_Python_Image Processing_Threshold_Laplacian - Fatal编程技术网

Python 图像阈值化不适用于拉普拉斯图像

Python 图像阈值化不适用于拉普拉斯图像,python,image-processing,threshold,laplacian,Python,Image Processing,Threshold,Laplacian,我需要对过滤图像的拉普拉斯算子进行阈值过零检测。但一旦应用拉普拉斯算子,在进行阈值处理时就会出现错误。有什么建议吗 代码: 错误: 你可以这样改变 retval, threshold = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO) 您需要指定所需的ddepth。看见拉普拉斯算子通常生成一个浮点图像-1:1。因此,您需要将图像缩放回8位0到255的范围。看见这是一个零交叉的链接。当您遇到问题时,应始终参考OpenCV文档和/或搜索Google和

我需要对过滤图像的拉普拉斯算子进行阈值过零检测。但一旦应用拉普拉斯算子,在进行阈值处理时就会出现错误。有什么建议吗

代码:

错误:


你可以这样改变

retval, threshold = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO)

您需要指定所需的ddepth。看见拉普拉斯算子通常生成一个浮点图像-1:1。因此,您需要将图像缩放回8位0到255的范围。看见这是一个零交叉的链接。当您遇到问题时,应始终参考OpenCV文档和/或搜索Google和本论坛。
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-23-e36300501b24> in <module>
      1 img = cv2.imread('H:/FYP/interim/aniso.jpg')
      2 lap = cv2.Laplacian(img, 1, ksize=5)
----> 3 retval, threshold = cv2.threshold(lap, 70, 255, cv2.THRESH_BINARY)
      4 plt.imshow(threshold)

error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\thresh.cpp:1612: error: (-210:Unsupported format or combination of formats)  in function 'cv::threshold'
retval, threshold = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO)