小编Kat*_*ice的帖子

提取二值图像中的最中心区域

我正在处理二进制图像,之前使用此代码来查找二进制图像中的最大区域:

# 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)

这段代码并没有真正完成我需要它做的事情,现在我认为最好提取二进制图像中最中心的区域。

二值图像 最大图像

这就是代码目前正在提取的内容,但我希望能够获得提取的第一个二进制图像中的中心圆。

python opencv image-processing binary-image

2
推荐指数
1
解决办法
514
查看次数

标签 统计

binary-image ×1

image-processing ×1

opencv ×1

python ×1