检测非常小的圆圈并获取其信息(Opencv)

发布于 2025-01-15 09:47:00 字数 1899 浏览 1 评论 0原文

我试图检测如图所示的每个小圆圈(它是横截面图像中子午线轮胎的胎圈部分)并获取它们的信息(可选)。为了改进检测过程,我执行了一些图像处理步骤,包括中值模糊和二值阈值(一般二值阈值和逆二值阈值)。我正在使用 HoughCicle 变换来检测圆圈,但是我卡住了并且无法检测到它。

请问,有什么建议吗?非常感谢。

这是原始图像

裁剪后的图像(这是我要检测的圆圈出现的区域)

这是二进制图像输出,并将其裁剪以删除不必要的部分

因此,我试图从下图所示的二进制图像中检测每个圆圈,如红色标记所示。 最终预处理图像

我使用了以下代码

import cv2
import numpy as np
import os
import matplotlib.pyplot as plt

############# preprocessing ##################


img = cv2.imread('BD-2021.png')
median_5 = cv2.medianBlur(img, 5)  # median filtering 
image_masked = cv2.cvtColor(median_5, cv2.COLOR_BGR2GRAY)   # converting to grayscael
res,thresh_img=cv2.threshold(image_masked,230,255,cv2.THRESH_BINARY_INV)  # inverse binary 
# res,thresh_img_b=cv2.threshold(image_masked,200,255,cv2.THRESH_BINARY)   # global binary 

height, width = thresh_img.shape
img_crop = thresh_img[int(0.7*height):height,:width] 

# reverse_thresh = cv2.cvtColor(thresh_img,cv2.COLOR_GRAY2BGR)

############# Hough circle detection ##################

c = cv2.HoughCircles(img_crop, cv2.HOUGH_GRADIENT,
                     minDist=2, dp=1, param1=70, 
                      param2=12, minRadius=0,maxRadius=5)
c = np.uint16(np.around(c))

for i in c[0,:]:
    # draw the outer circle
    cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
#     cv2.circle(reverse_thresh,(i[0],i[1]),i[2],(0,255,0),2)

    # draw the center of the circle
    cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)
#     cv2.circle(reverse_thresh,(i[0],i[1]),2,(0,0,255),3)



cv2.imshow('circle detected',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

,希望有任何建议?再次感谢您。

I am trying to detect each small circle (it is the bead part of the radial tires from the cross-sectional image)located as shown in the image and get their information(optional). To improve the detection process I have performed a few image processing steps including median blurring and binary thresholding (the general binary thresholding and inverse binary thresholding). I am using HoughCicle transform to detect the circles however I stucked and couldn't be able to detect it yet.

Please, any suggestions? Thank you very much.

This is the original image

Cropped image (it is the area where the circle I want to detect appear)

This is the binary image output and cropped it to remove the unnecessary part

As such, I'm trying to detect each circle from the binary image shown in the image below like marked in red.
Final preprocessed image

I used the following code

import cv2
import numpy as np
import os
import matplotlib.pyplot as plt

############# preprocessing ##################


img = cv2.imread('BD-2021.png')
median_5 = cv2.medianBlur(img, 5)  # median filtering 
image_masked = cv2.cvtColor(median_5, cv2.COLOR_BGR2GRAY)   # converting to grayscael
res,thresh_img=cv2.threshold(image_masked,230,255,cv2.THRESH_BINARY_INV)  # inverse binary 
# res,thresh_img_b=cv2.threshold(image_masked,200,255,cv2.THRESH_BINARY)   # global binary 

height, width = thresh_img.shape
img_crop = thresh_img[int(0.7*height):height,:width] 

# reverse_thresh = cv2.cvtColor(thresh_img,cv2.COLOR_GRAY2BGR)

############# Hough circle detection ##################

c = cv2.HoughCircles(img_crop, cv2.HOUGH_GRADIENT,
                     minDist=2, dp=1, param1=70, 
                      param2=12, minRadius=0,maxRadius=5)
c = np.uint16(np.around(c))

for i in c[0,:]:
    # draw the outer circle
    cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
#     cv2.circle(reverse_thresh,(i[0],i[1]),i[2],(0,255,0),2)

    # draw the center of the circle
    cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)
#     cv2.circle(reverse_thresh,(i[0],i[1]),2,(0,0,255),3)



cv2.imshow('circle detected',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

I would appreciate for any recommendation ? Thank you once again.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吾家有女初长成 2025-01-22 09:47:00

我建议使用斑点检测算法。该算法是 SIFT 描述符的第一部分,并且相当容易实现。斑点检测算法涉及使用高斯卷积拉普拉斯算子 (LoG) 来查找图片中的斑点,该卷积可近似为高斯差值。关于尺度空间以及如何实现斑点检测的一个很好的解释是 此处

I would recommend using the Blob Detection Algorithm. This algorithm is the first part of the SIFT descriptor and is fairly easy to implement. The blob detection algorithm involves finding blobs in the picture using the Laplacian of Gaussian convolution (LoG) which can be approximated as a difference of gaussians. A good explanation on the scale space and how to implement the blob detection is given here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文