图像阈值法在拉普拉斯图像处理中不起作用

2024-06-01 08:32:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要执行一个阈值过零检测滤波图像的拉普拉斯。但是一旦应用拉普拉斯算子,在进行阈值分割时就会产生误差。有什么建议吗?你知道吗

代码:

img = cv2.imread('H:/FYP/interim/aniso.jpg')
lap = cv2.Laplacian(img, 1, ksize=5)
retval, threshold = cv2.threshold(lap, 70, 255, cv2.THRESH_BINARY)
plt.imshow(threshold)

错误:

---------------------------------------------------------------------------
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'

Tags: imgthreshold阈值errorcv2jpgretvalimread