How to draw a disk of given center and radius ?
Show older comments
I have computed the center and radius and now I want to draw a white disk using these parameters on a black background. I tried something like below but its generating a flat edge in four directions. It is kind of urgent to compare the results so any help would be appreciated. I have attached two images to keep my point. Please zoom the images in order to see what am I claiming.
[imageSizeY,imageSizeX,d] = size(imgimg);
[columnsInImage, rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY);
centerX = floor(centroid(1));
centerY = floor(centroid(2));
radius = ceil(radii);
circlePixels = (rowsInImage - centerY).^2 + (columnsInImage - centerX).^2 <= radius.^2;
circlePixels = mat2gray(circlePixels);
%figure, imshow(circlePixels);
formatSpec_org = 'Proposed%d.png';
strProposed1 = sprintf(formatSpec_org, x);
strProposed2 = 'OutputFolder\';
s_P = strcat(strProposed2,strProposed1);
imwrite(circlePixels,s_P)
Accepted Answer
More Answers (1)
shamookh alqahtani
on 18 Feb 2020
0 votes
[imageSizeY,imageSizeX,d] = size(imgimg);
[columnsInImage, rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY);
centerX = floor(centroid(1));
centerY = floor(centroid(2));
radius = ceil(radii);
circlePixels = (rowsInImage - centerY).^2 + (columnsInImage - centerX).^2 <= radius.^2;
circlePixels = mat2gray(circlePixels);
%figure, imshow(circlePixels);
formatSpec_org = 'Proposed%d.png';
strProposed1 = sprintf(formatSpec_org, x);
strProposed2 = 'OutputFolder\';
s_P = strcat(strProposed2,strProposed1);
imwrite(circlePixels,s_P)
1 Comment
Image Analyst
on 18 Feb 2020
How is this different than the original code the poster posted? What did you change?
Categories
Find more on Color and Styling 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!