Posted on:

28 May 2025

0

Scikit-image equivalent logic

As an exercise, I tried to replicate this logic using the scikit-image library, but after a few hours of playing with the various parameters, I couldn't get it to identify the coin circles. Could someone please let me know if this is possible? Here is the code:
capstone_coins_updated = capstone_coins.copy()

capstone_gray_blur = ski.filters.gaussian(capstone_gray, sigma=3)
edges_cap = canny(capstone_gray_blur, sigma=0.01, low_threshold=None, high_threshold=None)


# Detect two(?) radii
hough_radii_cap = np.arange(80, 700, 5)
hough_res_cap = hough_circle(edges_cap, hough_radii_cap)

# Select the most prominent circles
accums_cap, cx_cap, cy_cap, radii_cap = hough_circle_peaks(hough_res_cap, hough_radii_cap, min_xdistance=5, min_ydistance=5, num_peaks=1, total_num_peaks=8)

# Draw them
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(12, 5))
#image = color.gray2rgb(image)
for center_y, center_x, radius in zip(cy_cap, cx_cap, radii_cap):
    circy_cap, circx_cap = circle_perimeter(center_y, center_x, radius, shape=capstone_coins_updated.shape)
    capstone_coins_updated[circy_cap, circx_cap] = (220, 20, 20)

ax.imshow(capstone_coins_updated, cmap=plt.cm.gray)
plt.show()
0 answers ( 0 marked as helpful)

Submit an answer