Labeling an Image (houghcircle)

6 次查看(过去 30 天)
Calvin
Calvin 2022-11-7
回答: Maik 2022-11-7
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)

回答(1 个)

Maik
Maik 2022-11-7
% 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

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by