Question
MATLAB At the end of the code, I'm trying to separate the coins based of radii but it ain't working properly, it's recording all 33
MATLAB At the end of the code, I'm trying to separate the coins based of radii but it ain't working properly, it's recording all 33 coins for each category. Please help!!!
clc; close all; clear all;
rgb = imread('coins.jpg'); figure imshow(rgb)
d = drawline; pos = d.Position; diffPos = diff(pos); diameter = hypot(diffPos(1),diffPos(2)) gray_image = rgb2gray(rgb); figure imshow(gray_image) [centers,radii] = imfindcircles(rgb,[20 40],'ObjectPolarity','dark') [centers,radii] = imfindcircles(rgb,[20 40],'ObjectPolarity','dark', ... 'Sensitivity',0.9) figure imshow(rgb) h = viscircles(centers,radii); [centers,radii] = imfindcircles(rgb,[20 40],'ObjectPolarity','dark', ... 'Sensitivity',0.92);
length(centers) delete(h) h = viscircles(centers,radii); [centers,radii] = imfindcircles(rgb,[20 40],'ObjectPolarity','dark', ... 'Sensitivity',0.92,'Method','twostage');
delete(h) h = viscircles(centers,radii); [centers,radii] = imfindcircles(rgb,[20 40],'ObjectPolarity','dark', ... 'Sensitivity',0.95);
delete(h) viscircles(centers,radii); figure imshow(gray_image) [centersBright,radiiBright] = imfindcircles(rgb,[20 40], ... 'ObjectPolarity','bright','Sensitivity',0.92); figure imshow(rgb)
hBright = viscircles(centersBright, radiiBright,'Color','b'); [centersBright,radiiBright,metricBright] = imfindcircles(rgb,[20 40], ... 'ObjectPolarity','bright','Sensitivity',0.92,'EdgeThreshold',0.05);
delete(hBright) hBright = viscircles(centersBright, radiiBright,'Color','b'); h = viscircles(centers,radii);
B = sort(radii); disp(B)
penny = (B >= 23.8086) & (B = 24.8442) & (B = 25.0321) & (B = 30.8523) & (B
disp(penny) numpennies = numel(penny); numfiver = numel(fiver); numdime = numel(dime); numquarter = numel(quarter);
totalvalue = (numpennies*1 + numfiver*5 + numdime*10 + numquarter*25); disp(totalvalue)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started