62 views (last 30 days)

Image Analyst
on 10 Oct 2019

Use sind() and cosd() to get all the x and y coordinates. Round them to get integers and use unique() with the rows option to remove duplicates. Try this:

radius = 50

xCenter = 500;

yCenter = 500;

rows = 720

columns = 1280

theta = linspace(0, 360, 4*pi*radius); % More than needed to avoid gaps.

x = xCenter + radius * cosd(theta);

y = yCenter + radius * sind(theta);

grayImage = 128 * ones(rows, columns, 'uint8');

xy = round([x', y']);

xy = unique(xy, 'rows');

x = xy(:, 1);

y = xy(:, 2);

for k = 1 : length(x)

grayImage(y(k), x(k)) = 255;

end

imshow(grayImage);

axis('on', 'image');

fprintf('Done!\n');

Matt J
on 10 Oct 2019

Okay Considering 5 pixels + or - for the inaccuracy to find all the x,y, points on the circumference; how can I find even those.

Dsq=( (1:1280).'-500 ).^ + ((1:720)-500).^2;

idx = (Dsq>=(50-5).^2) & (Dsq<=(50+5).^2) ;

[X,Y]=ndgrid(1:1280,1:720);

CircumferencePixels=[X(idx), Y(idx)];

Opportunities for recent engineering grads.

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

Start Hunting!
## 2 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/484501-find-the-points-on-circumference-of-a-circle#comment_754575

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/484501-find-the-points-on-circumference-of-a-circle#comment_754575

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/484501-find-the-points-on-circumference-of-a-circle#comment_754582

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/484501-find-the-points-on-circumference-of-a-circle#comment_754582

Sign in to comment.