简体   繁体   English

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

[英]Image thresholding not working on Laplacian image

I need to perform a thresholded zero-crossing detection of the filtered image's laplacian.我需要对过滤后的图像的拉普拉斯算子进行阈值过零检测。 But once the laplacian is applied, it gives error when doing thresholding.但是一旦应用拉普拉斯算子,在进行阈值处理时就会出错。 Any advice?有什么建议吗?

code:代码:

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:错误:

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

you can change like this你可以这样改变

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM