I have a 128 X 128 matrix that represents an image.
What I want to do is create a filled circle in the matrix with the
center at a given point and of a given radius and filled with a given
value.
What is the easiest way to do something like this?
Cheers,
Luc
Generate two matrices of coordinates x and y. Then operate on those
coordinates to produce whatever you want. In this case, calculate the
distance from your point. If that distance is < R, the point is inside
the circle. Etc.
[x y] = meshgrid(1:128, 1:128);
imagesc(x)
imagesc(sqrt(x.^2 + y.^2))
imagesc(sqrt((x-64).^2 + y.^2))
etc.
-Peter
hi,
i have the following matlab code to draw a circle. I want
to know how i can fill the circle with black.
t = linspace(0,2*pi,1000);
h=0;
k=0;
r=10;
x = r*cos(t)+h;
y = r*sin(t)+k;
plot(x,y);
axis square;
I also want to know how i can cut the circle in such a way
that the four quarters of the circle which are black in
color move to the corners.
Thanks,
Vikas
>i have the following matlab code to draw a circle. I want
>to know how i can fill the circle with black.
>t = linspace(0,2*pi,1000);
>h=0;
>k=0;
>r=10;
>x = r*cos(t)+h;
>y = r*sin(t)+k;
>plot(x,y);
>axis square;
Instead of plot(x,y), fill(x,y,'k')
--
"Okay, buzzwords only. Two syllables, tops." -- Laurie Anderson
In Matlab there is a function Delaunay to construct the Delaunay Graph
of a 2 dimension set of points. Does anyone have/know how to compute
the source code for drawing the Gabriel Graph using Matlab?
The Gabriel graph of a set P of points in the plane is defined as
follows: Two points p and q are connected by an edge of the Gabriel
graph if and only if the circle with diameter pq does not contain any
other point of P in its interior.
Believe it or not, you actually use the MATLAB rectangle
command to draw circles. The following code will draw a
circle of radius 3 centered at x=0 & y=0:
>> radius = 3;
>> w = radius;
>> h = radius;
>> x = 0;
>> y = 0;
>> rectangle('Position',[x,y,w,h],'Curvature',[1,1])
>>
Oops... Forgot the last part of your question.
To fill the above circle with green, use:
rectangle('Position',[x,y,w,h],'Curvature',
[1,1],'FaceColor','g'))