Labeling an Image (houghcircle)

5 views (last 30 days)
Calvin
Calvin on 7 Nov 2022
Answered: Maik on 7 Nov 2022
I have a code that takes an image of coins and draws the respective hough circles around them as well as gives me the circle's radius in a resulting vector. I want to take the radiuses generated in the vector and place them on the respective circle that they align with and I am hvaing an issue doing so. I have tried plotting the values; however, it gives me a different graph. I want the image with the hough circles to have the corresponsing values on that graph as well.Thanks!
Code:
clear all
clc
%Show Image in GrayScale
I = imread('1.png');
imshow(I)
BWI = im2gray(I);
figure
imshow(BWI)
%%Increase Sensitivity if the coins/circles are not found, Make sure radius is correct and includes entire range
[centers,radii] = imfindcircles(BWI,[10 74],'ObjectPolarity','bright', 'Sensitivity',0.93);
viscircles(centers,radii,'color','r')
length(centers)

Answers (1)

Maik
Maik on 7 Nov 2022
% Code:
clear all
clc
%Show Image in GrayScale
I = imread('coins.png');
imshow(I)
BWI = im2gray(I);
figure
imshow(BWI)
%%Increase Sensitivity if the coins/circles are not found, Make sure radius is correct and includes entire range
[centers,radii] = imfindcircles(BWI,[8 74],'ObjectPolarity','bright', 'Sensitivity',0.93);
viscircles(centers,radii,'color','r')
ans =
Group with properties: Children: [2×1 Line] Visible: on HitTest: on Show all properties
length(centers)
ans = 10
% Draw Radius Function
for i = 1:size(centers,1)
line([centers(i,1) centers(i,1)],[centers(i,2) centers(i,2)+radii(i,1)], 'color', 'b' );
end

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!