clc;clear;close all;
impath = 'metal-parts-01.png';
img = imread(impath);
F1= edge(img,'Canny',0.5,0.3);
figure();
imshowpair(img, F1, 'montage');
title(' Canny')
[A,theta,rho] = hough (F1);
peaks = houghpeaks(A,5,'Threshold',5);
lines = houghlines (F1,theta,rho,peaks);
figure()
imshow(img), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
end
LowD = 6; LowL =25;
HighD =25; HighL = 80;
[centersL,radiiL]=imfindcircles(img,[LowL HighL],'ObjectPolarity','bright','Sensitivity',0.95);
[centersD,radiiD]=imfindcircles(img,[LowD HighD],'ObjectPolarity','dark','Sensitivity',0.90);
viscircles(centersD,radiiD);
viscircles(centersL,radiiL);