[英]Python: Return position and size of arbitrary/teeth shapes in image using OpenCV
I'm very new to the image processing and object detection.我对图像处理和 object 检测非常陌生。 I'd like to extract/identify the position and dimensions of teeth in the following image:
我想在下图中提取/识别 position 和牙齿尺寸:
Here's what I've tried so far using OpenCV:这是我到目前为止使用 OpenCV 尝试过的内容:
import cv2
import numpy as np
planets = cv2.imread('model.png', 0)
canny = cv2.Canny(planets, 70, 150)
circles = cv2.HoughCircles(canny,cv2.HOUGH_GRADIENT,1,40, param1=10,param2=16,minRadius=10,maxRadius=80)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(planets,(i[0],i[1]),i[2],(255,0,0),2)
# draw the center of the circle
cv2.circle(planets,(i[0],i[1]),2,(255,0,0),3)
cv2.imshow("HoughCirlces", planets)
cv2.waitKey()
cv2.destroyAllWindows()
This is what I get after applying canny filter:这是我应用精明过滤器后得到的:
This is the final result:这是最终结果:
I don't know where to go from here.我不知道 go 从这里到哪里。 I'd like to get all of the teeth identified.
我想把所有的牙齿都鉴定出来。 How can I do that?
我怎样才能做到这一点?
I'd really appreciate any help..我真的很感激任何帮助..
Note that the teeth-structure is more-or-less a parabola (upside-down).请注意,牙齿结构或多或少是抛物线(倒置)。 If you could somehow guess the parabolic shape that defines the centroids of those blobs (teeth), then your problem could be simplified to a reasonable extent.
如果您能以某种方式猜测定义这些斑点(牙齿)质心的抛物线形状,那么您的问题可以在合理的程度上简化。 I have shown a red line that passes through the centers of the teeth.
我展示了一条穿过牙齿中心的红线。
I would suggest you to approach it as follows:我建议您按以下方式处理它:
sklearn.preprocessing.binarize
.sklearn.preprocessing.binarize
。structure_centroid
.structure_centroid
。 See this: How to center the nonzero values within 2D numpy array?structure_centroid
.structure_centroid
的位置为中心。 I have shown a cartoon image of such polar slices (triangular semi-transparent).polarTransform
library .polarTransform
库。centroid_path
.centroid_path
。centroid_path
.centroid_path
的圆圈上运行消除/选择算法。 Use a threshold distance to drop the outliers. This should give you a good approximation of the teeth with the circles.这应该给你一个很好的与圆圈的牙齿近似值。
I hope this helps.我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.