How to implement a funtion to 'Count an amount of one type of lego piece in the Image'?

20 views (last 30 days)
Sorry if it's a lot to ask but is there an easy way to implement a function that takes in the image of cluster of lego pieces and returns the count of a particular type of Lego piece? i.e. given the lego piece type shown in the first image--------->
how to implement a function that return the amount of the same type of lego pieces existed in the image below.
Thank you very much in advance!!
Baz

Accepted Answer

Image Analyst
Image Analyst on 19 Jan 2015
First you have to do color segmentation to get separate, individual blocks. See my File Exchange for demos: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Then try using imfindcircles() to count the circles in each colored brick. Here is a demo: http://www.mathworks.com/matlabcentral/fileexchange/34365-circle-finder
  7 Comments
Image Analyst
Image Analyst on 13 Jan 2019
Well of course you can ask regionprops() for the BoundingBox, but I think you may want the Feret Diameters.
Shruti Jha
Shruti Jha on 8 Dec 2020
Adding on to this thread, I have a similar problem. I am able to isolate blue coloured legos, however when I perform edge detection and filling, I get something like this (the last image).
Now, I'm not sure how to fill all the others and separate out the rectangular ones. Can somebody please help?
Much appreciated!

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Support Package for LEGO MINDSTORMS EV3 Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!