How to make connected circle network in 2D on 144*144 pixel size square plane in matlab ?

1 Ansicht (letzte 30 Tage)
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.

Antworten (1)

darova
darova am 20 Apr. 2019
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 Kommentare
Shubham Saraf
Shubham Saraf am 23 Apr. 2019
Thanks Darova to help me for generating network of circle.
I have a desired output but same problem occurred matlab code size was long can't able to apply for loop on
hLine = imline(gca,[x1 x2],[y1 y2]);
My running code was:
imageSizeX = 640;
imageSizeY = 480;
[X, Y] = meshgrid(1:imageSizeX, 1:imageSizeY);
I = false(size(X));
xc = 64:64:576;
yc = 48:48:432;
r = 10;
for i = 1:length(xc)
for j = 1:length(yc)
circ = (Y - yc(j)).^2 + (X - xc(i)).^2 <= r^2;
I = I | circ;
end
end
imshow(I)
hLine1 = imline(gca,[1 640],[48 48]);hLine2 = imline(gca,[1 640],[96 96]);hLine3 = imline(gca,[1 640],[144 144]);hLine4 = imline(gca,[1 640],[192 192]);
hLine5 = imline(gca,[1 640],[240 240]);hLine6 = imline(gca,[1 640],[288 288]);hLine7 = imline(gca,[1 640],[336 336]);hLine8 = imline(gca,[1 640],[384 384]);
hLine9 = imline(gca,[1 640],[432 432]);hLine10 = imline(gca,[64 64],[1 480]);hLine11 = imline(gca,[128 128],[1 480]);hLine12 = imline(gca,[192 192],[1 480]);
hLine13 = imline(gca,[256 256],[1 480]);hLine14 = imline(gca,[320 320],[1 480]);hLine15 = imline(gca,[384 384],[1 480]);hLine16 = imline(gca,[448 448],[1 480]);
hLine17 = imline(gca,[512 512],[1 480]);hLine18 = imline(gca,[576 576],[1 480]);
mask1 = hLine1.createMask();mask2 = hLine2.createMask();mask3 = hLine3.createMask();mask4 = hLine4.createMask();
mask5 = hLine5.createMask();mask6 = hLine6.createMask();mask7 = hLine7.createMask();mask8 = hLine8.createMask();
mask9 = hLine9.createMask();mask10 = hLine10.createMask();mask11 = hLine11.createMask();mask12 = hLine12.createMask();
mask13 = hLine13.createMask();mask14 = hLine14.createMask();mask15 = hLine15.createMask();mask16 = hLine16.createMask();
mask17 = hLine17.createMask();mask18 = hLine18.createMask();
I = I | mask1| mask2| mask3| mask4| mask5| mask6| mask7| mask8| mask9| mask10| mask11| mask12| mask13| mask14| mask15| mask16| mask17| mask18;
imshow(I)
title('Binary image of circle connect by line');
My output image: Binary_image_circle_network.jpg
Now, Help me to solve which I want to compress matlab code by using for loop, how to apply it on above code and also connected line width dimension changes from 1 pixel to 10 pixel.
Thank you for your kind of consideration.
Sincerely,
Shubham Saraf
darova
darova am 23 Apr. 2019
Hi, look attached files. Think how to create origins using loops
Read about imdilate()

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by