Finding square centers from a picture

After an Image Processing, from fft's, filters, and thresholding, I obtained the following image:

So, I'm wondering how to extract those centers. Does exist any function from OpenCV? (such as HoughCircles for detecting circles?) or Do I need to use clustering methods?

Maybe it is useful for you to know the code I used:

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: So I have another question, it could be useful for some of you. The maximum_filter function gave me the "3 squares"(then I'll get a better visualization of them by using thresholding), so is there a way to use the maximum_filter function and to obtain "3 circles"? Then we can use HoughCircles to obtain the 3 centers circles.


You may need to use Image Moments.

As the pre-processing steps, threshold the source to create mask of squares, and then pass to findcontours.

链接地址: http://www.djcxy.com/p/79636.html

上一篇: 实时图像处理:HSV图像中的噪声(openCV)

下一篇: 从照片中找到广场中心