How can I draw a circle on an image in MATLAB?
I have an image in MATLAB:
im = rgb2gray(imread('some_image.jpg'); % normalize the image to be between 0 and 1 im = im/max(max(im));
And I've done some processing that resulted in a number of points that I want to highlight:
points = some_processing(im);
Where points
is a matrix the same size as im
with ones in the interesting points.
Now I want to draw a circle on the image in all the places where points
is 1.
Is there any function in MATLAB that does this? The best I can come up with is:
[x_p, y_p] = find (points); [x, y] = meshgrid(1:size(im,1), 1:size(im,2)) r = 5; circles = zeros(size(im)); for k = 1:length(x_p) circles = circles + (floor((x - x_p(k)).^2 + (y - y_p(k)).^2) == r); end % normalize circles circles = circles/max(max(circles)); output = im + circles; imshow(output)
This seems more than somewhat inelegant. Is there a way to draw circles similar to the line
function?
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Answers:
You could use the normal PLOT command with a circular marker point:
[x_p,y_p] = find(points); imshow(im); %# Display your image hold on; %# Add subsequent plots to the image plot(y_p,x_p,'o'); %# NOTE: x_p and y_p are switched (see
SEE COMPLETE ANSWER CLICK THE LINK
https://matlabhelpers.com/questions/how-can-i-draw-a-circle-on-an-image-in-matlab-.php
Comments
Post a Comment