How to make connected circle network in 2D on 144*144 pixel size square plane in matlab ?
2 次查看(过去 30 天)
显示 更早的评论
Hello Everyone,
I,Shubham saraf want to draw 2D image with (38*38)mm image size black pixel plane and put connected network model of circles on it, with Radius = 0.02 mm, Connected length = 0.24 mm. (1 pixel = 0.2646 mm)
what is the matlab code for it? please response me as soon as possible if any know.
Reference image which type output required, it was attached.
I used this code but get single circle output so now generate network provide loop for it.
Matlab code:
% Create a logical image of a circle with specified
% diameter, center, and image size.
% First create the image.
imageSizeX = 640;
imageSizeY = 480;
[columnsInImage rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY);
% Next create the circle in the image.
centerX = 320;
centerY = 240;
radius = 100;
circlePixels = (rowsInImage - centerY).^2 + (columnsInImage - centerX).^2 <= radius.^2;
% circlePixels is a 2D "logical" array.
% Now, display it.
image(circlePixels) ;
colormap([0 0 0; 1 1 1]);
title('Binary image of a circle');
Thank you for your consideration.
0 个评论
回答(1 个)
darova
2019-4-20
Use loops
clc , clear
% image size
imageSizeX = 640;
imageSizeY = 480;
[X, Y] = meshgrid(1:imageSizeX, 1:imageSizeY);
I = false(size(X));
% circle centers.
xc = [100 150 200 450 500];
yc = [140 250 350];
% circle radius
radius = 10;
for i = 1:length(xc)
for j = 1:length(yc)
circ = (Y - yc(j)).^2 + (X - xc(i)).^2 <= radius^2;
I = I | circ;
end
end
% circlePixels is a 2D "logical" array.
% Now, display it.
imshow(I)
title('Binary image of a circle');
8 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!