Hi, I need to write a function that calculates how many coins are in a picture and determines there combined value, I have the following code that works for a stock image, but I cant seem to apply it to work with an image containing Australian coins, such as this:
Here is the current code I have:
_______________________________________________________coin1 = im2bw(imread('coins.png'));coin2 = imfill(coin1,'holes');[L Ne]=bwlabel(double(coin2));prop=regionprops(L,'Area','Centroid');total=0;imshow(imread('coins.png'));hold onfor n=1:size(prop,1) doll=prop(n).Centroid; X=doll(1);Y=doll(2); if prop(n).Area>2000 text(X-10,Y,'$1') total=total+1; else total=total+2; text(X-10,Y,'$2') endendnumber = ndollar = totalhold ontitle(['Dollars: $',num2str(dollar),' ', 'Number of coins:',num2str(n)])_________________________________________________________________
Any help would be appreciated, thanks
Best Answer