How to identify black dots on dice via image processing? (MATLAB)
3 views (last 30 days)
Show older comments
Hi, I have some pictures of two white dices with black dots, and I need to recognize the value on each visible face of dices. For example, from this image:
I need to get [5 6]. Any ideas?
It's really urgent, I need to submit my final project and this is the last piece. Thanks a lot!
0 Comments
Answers (1)
Image Analyst
on 11 Oct 2015
It's not too hard. Of course it would be easier if you could start out with a good image. Why are you zoomed out so much and tossing the dice on a varying background? Why don't you toss them onto a dark background, like black velvet? This would reduce the chance you need to do any noise cleanup. If you're luck, you can just threshold for dark spots and call bwlabel() to count them
[!, numSpots] = bwlabel(grayImage < 128); % or whatever value works.
You can also adapt my Image Segmentation Tutorial for a full demo. Just reverse the direction of the < sign so that you threshold for dark spots instead of light spots. Here is the code: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
If it fails for some images, then there are some things you can do, like first threshold for white (assuming that the only white will be on the dice), Then fill the holes with imfill() and then use this as a mask on the whole image. Then find the black spots.
2 Comments
Image Analyst
on 11 Oct 2015
Then first you'll need to identify each dice one at a time. First threshold for white and look for blobs of the right size. Then, if there is none but only a blob about twice as large, then the dice are touching and you'll have to split it apart with imerode. Then use your algorithm on each die one at a time.
See Also
Categories
Find more on Visual Exploration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!