当图像和背景中的对象具有几乎相同的颜色时,如何有效执行边缘检测? 我尝试使用下面的代码,但没有给出我想要的:
import cv2
import matplotlib.pyplot as plt
image = cv2.imread("image1.JPG")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.bilateralFilter(gray, 11, 17, 17)
edged = cv2.Canny(gray, 10, 150)
edged = cv2.dilate(edged, None, iterations=1)
edged = cv2.erode(edged, None, iterations=1)
plt.imshow(edged)
plt.show()