【问题标题】:Finding square centers from a picture从图片中找到正方形中心
【发布时间】:2014-08-11 20:07:37
【问题描述】:

经过 fft、过滤器和阈值处理的图像处理后,我得到了以下图像:

所以,我想知道如何提取这些中心。是否存在来自 OpenCV 的任何功能? (例如用于检测圆圈的 HoughCircles?)或者我需要使用聚类方法吗?

也许知道我使用的代码对你有用:

import cv2
import numpy as np
import scipy.ndimage as ndimage 
from scipy.ndimage import maximum_filter

img = cv2.imread("pic.tif",0)

s = np.fft.fftshift(np.fft.fft2(img))

intensity = 20 * np.log(np.abs(s))
maxs = maximum_filter(intensity, 125)
maxs[maxs < intensity] = intensity.max()

ret, thresh = cv2.threshold(maxs.astype('uint8'),0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
imshow(thresh)

PS:所以我还有一个问题,它可能对你们中的一些人有用。 maximum_filter 函数给了我“3 个正方形”(然后我将通过使用阈值得到更好的可视化),那么有没有办法使用 maximum_filter 函数并获得“3 个圆圈”?那么我们就可以用HoughCircles得到3个中心圆了。

【问题讨论】:

    标签: python opencv image-processing detection


    【解决方案1】:

    您可能需要使用Image Moments

    作为预处理步骤,threshold 源创建正方形掩码,然后传递给findcontours

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-22
      • 1970-01-01
      相关资源
      最近更新 更多