Hi – this is some code that I found of the matlabs wiki. I am trying to modify it to suit my use and am struggling greatly to achieve the required outcome.
Basically this creates 1 circle within an array. The circle is designated as 1s and everything outside the circle are 0s.
However, I have an unknown amount of circles (similar radi but different X and Y for centers)
What I want to do is to create multiple circles within this array. Eventually hopefully, I will return a final array that has a 1 where a circle overlaps and 0 where no circle has overlapped.
Would the following code be modifiable or would I need a different approach?
% 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');
Best Answer