Plot a circle of desired intensity.

3 visualizaciones (últimos 30 días)
Jose Aroca
Jose Aroca el 11 de Jun. de 2020
Comentada: Image Analyst el 12 de Jun. de 2020
I have the following code to draw a white square on a black background. The intensity of the square can be varied from 0 to 256 from black to white.
backg = uint8(zeros(500,500,3));%produce 500x500 px background
for x = 200:1:300; %define x limits of square
for y = 200:1:300; %define y limits of square
backg(x,y,:) = 256; %choose intensity
end;
end;
image(backg);
I would like to use the same code to plot a circle, but I get errors related to array indices.
Many thanks.
  1 comentario
darova
darova el 12 de Jun. de 2020
Do you know how to draw a circle?

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 12 de Jun. de 2020
Adapt as needed (center location, radius, intensity, etc.).
  2 comentarios
Jose Aroca
Jose Aroca el 12 de Jun. de 2020
Yeah, I saw that before. However, I want a circle in which the intensity can be varied. I developed this code in which the intensity can be varied according to the radius.
imagelength=100;
middle=(imagelength+1)/2;
radius=20;
dimmerRadius=15;
brightness=256;
dimmerBrightness=150;
image=ones(imagelength);
for i=1:imagelength
x=-imagelength+middle+i; %change y coordinate by adding term
for j=1:imagelength
y=-imagelength+middle+j; %change x coordinate by adding term
if(x^2+y^2<=radius^2) %equation of desired shape
image(i,j)=brightness;
end
if(x^2+y^2<=dimmerRadius^2)
image(i,j)=dimmerBrightness;
end
end
end
imagesc(image)
axis square
axis off
colormap gray
caxis([1 256])
However, I want the intensity to vary as a Gaussian, ie. to be maximum at the centre and tail off as r is increased. Any ideas?
Image Analyst
Image Analyst el 12 de Jun. de 2020
See my attached demo. Adapt as needed.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Blue en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by