I have this image with this kind of shapes:
and what I do is to detect circle shapes with a certain radius range, using the Hough Transform through the scikit-image library:
# Load picture and detect edges sf_img = np.load('/..../sf_images.npy') # (num_img x 256 x 256) image = img_as_ubyte(sf_img[0,:,:]) edges = canny(image, sigma=3, low_threshold=10, high_threshold=50) # Detect two radii hough_radii = np.arange(235, 236, 2) hough_res = hough_circle(edges, hough_radii) # Select the most prominent 40 circles accums, cx, cy, radii = hough_circle_peaks(hough_res, hough_radii, total_num_peaks=40) # Draw them fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(10, 4)) image = color.gray2rgb(image) for center_y, center_x, radius in zip(cy, cx, radii): circy, circx = circle_perimeter(center_y, center_x, radius, shape=image.shape) image[circy, circx] = (220, 20, 20) ax.imshow(image, cmap=plt.cm.gray) ax.scatter(cx,cy, marker= 'o') plt.show()
and running this script I obtain this image:
which is quite good because I obtain also an array with the centers of the circles and I can select also the center of the circular shape that got the most on the accumulator. In this case che coordinate of the center is [204,4].
FOR THE CURIOUS I’m trying to use the information of this soundfield image to detect the coordinate of a source which is emitting it, on the x-axis
Now, what I want to achieve is to have the same result but in a different unit scale for the axis:
that is, the new scale is [-2,2] (meters) for the x-axis and [2,4] (meters) for the y-axis.
I could of course modify the extent parameter of the image from the script like this:
ax.imshow(image, cmap=plt.cm.gray, extent= [-2,2,2,4])
but when I add the scatter function to show the center I got this:
and this is happening because the center coordinate keep the old corrdinates in the range 0,256 and not the new one, soo I was wandering if there was a way to change the center values in order for them to be coherent with the new scale of the image.