我正在处理二进制图像,之前使用此代码来查找二进制图像中的最大区域:
# Use the hue value to convert to binary
thresh = 20
thresh, thresh_img = cv2.threshold(h, thresh, 255, cv2.THRESH_BINARY)
cv2.imshow('thresh', thresh_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# Finding Contours
# Use a copy of the image since findContours alters the image
contours, _ = cv2.findContours(thresh_img.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
#Extract the largest area
c = max(contours, key=cv2.contourArea)
Run Code Online (Sandbox Code Playgroud)
这段代码并没有真正完成我需要它做的事情,现在我认为最好提取二进制图像中最中心的区域。
这就是代码目前正在提取的内容,但我希望能够获得提取的第一个二进制图像中的中心圆。