1 year ago
#324863
Paul Engelbert
From Hough Circle detection to coin separation
For an image analysis problem I'm trying to separate 11 unique, partly overlapping, coins and output an image with the coins separated and displayed in 11 different colors. I've done a Hough Circle Detection and found the individual circles.
Now I want to separate the overlapping coins and give all the coins an unique color. I already have a code where the different coins gets a different color + a unique number but a intermediate step is necessary. Im supposed to use scikit-image and not cv2.
The code for the coloring is:
from skimage.measure import label, regionprops
from skimage.morphology import remove_small_objects
from skimage.color import label2rgb
from skimage import filters
import math
im = image_where_coins_are_separated
im = im.astype(float)
im = im-im.min()
im = im/im.max()
block_size = 201
imbw1 = im > filters.threshold_local(im, block_size, method = 'mean')
imbw1 = remove_small_objects(imbw1, 1000, connectivity=1)
# connect the components
label_img = label(imbw1)
image_label_overlay = label2rgb(label_img, image=im, bg_label = 0)
regions = regionprops(label_img)
plt.figure(figsize=(8,8))
plt.imshow(image_label_overlay, cmap=plt.cm.gray)
for (i, props) in zip(range(len(regions)), regions):
y1, x1 = props.centroid
plt.text(x1, y1,(i + 1),color='w')
plt.axis('off')
To conclude, I'm looking for a line of code that provides the separation of overlapping coins after Hough Circle Detection and makes it usable for the code above. The output should be a display of all the 11 coins with 11 different colors and counts from 1 - 11.
python
image
object-detection
scikit-image
houghlines
0 Answers
Your Answer