Counting just coins in this image !...
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
I tried below code to count coins in image and it's work fine :
function ret = CountCoins(img)
subplot(2,2,1);
imshow(img);
subplot(2,2,2);
imgBW = im2bw(img);
imshow(imgBW);
subplot(2,2,3);
imhist(img);
subplot(2,2,4);
imgZ = zeros(size(img));
imgZ(img > 100) = 1;
imshow(imgZ);
ret = round(sum(imgBW(:)) / 2100);
imgConn = bwconncomp(imgZ);
ret = imgConn.NumObjects;
end
I want just count coins no anything else.
Look...
With above function i can count coins in this image :
Result is 10.(Correct)

But result of this image is wrong;
Result is 12.(Wrong)

because 2 shapes are not coins!
_______________________________________
My question:
How can i count "Just" coins on that image?
1 Kommentar
Walter Roberson
am 1 Mär. 2013
Define "coins" in a way that allows them to be distinguished with a picture of the resolution you show.
Akzeptierte Antwort
Image Analyst
am 1 Mär. 2013
Did you see my image segmentation tutorial: http://www.mathworks.com/matlabcentral/fileexchange/25157-image-segmentation-tutorial-blobsdemo? I do exactly that, plus a bunch of other useful things. I find 5 cent and 10 cent pieces based on their area. What you want to do is to adapt that to look at something else, like a combination of MeanIntensity and circularity (the ratio of perimeter^2 over (4*pi*area)), or you might want to use the standard deviation in the blob. Then use ismember() to extract out just the blobs that you want. My demo shows you how to do all that, you just need to adapt it slightly, like I said.
4 Kommentare
Walter Roberson
am 1 Mär. 2013
I'm not sure how you are going to match the guitar coins and distinguish them from guitar jewelry...
Image Analyst
am 1 Mär. 2013
Bearbeitet: Image Analyst
am 1 Mär. 2013
Get your binary image like this:
binaryImage = originalImage > 100 & originalImage < 250;
binaryImage = bwareaopen(binaryImage, 500);
It assumes those non-coin shapes will have an intensity of 250 or brighter.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!