how to copy circle for a new image using imfindcircle?

3 views (last 30 days)
i have this code and i need to copy the circle part of the image to a new image and for the life of me i cant figure out a way to do it.. thanks in advance!!
A = imread('Speed.jpg');
% Resize the image
rowSZ = size(A, 1);
colSZ = size(A, 2);
rows = 250*(colSZ/rowSZ);
J = imresize(A, [rows 250]);
% Show image
imshow(J)
% Set circle radius to find
Rmin = 50;
Rmax = 100;
% Find circles within the raidus
[centers, radii, metric] = imfindcircles(J,[Rmin Rmax]);
% Show circle on the image
viscircles(centers, radii,'EdgeColor','b');

Answers (1)

Devineni Aslesha
Devineni Aslesha on 2 Mar 2020
Use the code below to copy circle for a new image using 'imfindcircle'.
theta=0:1:360;
r=round(centers(1,1) + radii*sin(theta));
c=round(centers(1,2) + radii*cos(theta));
for j=1:length(r)
B(c(j),r(j),:)=[0 0 255];
end
figure(2)
imshow(B)
For more information, refer the following link.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!