使用左右分割图像检测对象位置

问题描述 投票:1回答:1

我需要找到图像中下方肿瘤的位置,即大脑的左侧或右侧。

current image

我尝试使用轮廓线并加了边缘以检测侧面,但似乎不适用于我的输出。

# Find Canny edges 
edged = cv2.Canny(img, 30, 200) 
cv2.waitKey(0) 

# Finding Contours 
# Use a copy of the image e.g. edged.copy() 
# since findContours alters the image 
contours, hierarchy = cv2.findContours(edged,  
    cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 

cv2.imshow('Canny Edges After Contouring', edged) 
cv2.waitKey(0) 

print("Number of Contours found = " + str(len(contours))) 

# Draw all contours 
# -1 signifies drawing all contours 
cv2.drawContours(img, contours, -1, (0, 255, 0), 3) 

image with edges and contours

python image-processing opencv-drawcontour
1个回答
0
投票

cannyfindContours不是解决此类问题的好方法。如果您想要一个简单的解决方案,只需使用阈值方法。大津门槛也会给你一个很好的结果。

© www.soinside.com 2019 - 2024. All rights reserved.