Plot a circle of Gaussian varying intensity

36 vues (au cours des 30 derniers jours)
Jose Aroca
Jose Aroca le 12 Juin 2020
Commenté : Image Analyst le 7 Jan 2021
I want to plot a circle who's intensity varies as a Gaussian distribution, ie. to be maximum at the centre and tail off as the radius is increased. I have developed this code in which the intensity can vary according to the radius, but I am unsure on how to follow.
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 circle
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])
Many thanks.

Réponse acceptée

Image Analyst
Image Analyst le 12 Juin 2020
See my attached demo. There are lots of parameters to control exactly the way it looks so adapt them to get what you want.
  25 commentaires
Image Analyst
Image Analyst le 30 Juin 2020
Looks like you need to make sure your sigmas occur in a tighter range. A bigger sigma will flatten out, almost like it's adding a constant to the image.
reham elnabawy
reham elnabawy le 2 Juil 2020
Image Analyst:
ok. I got your point. I minimized the sigma value so that the blurriness is removed. However, I can see that the circle shape is dissapeared meaning that, all the circles are drawn now as squares as shown in the attached figure. So how could I reconstruct the circle shape ?

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 2 Juil 2020
I don't see squares, except if you look at 45 degrees, but that's what you get when you use a hex grid. I think you should use a higher resolution image so you don't have such severe quantization artifacts.
  4 commentaires
reham elnabawy
reham elnabawy le 7 Jan 2021
Image Analyst: I need your assistnace in something please. I have a certain MATLAB code that I would like to run on a certain device. I need to know the execution time for my MATLAB code on this device. Please note that I don't have the device. However, I know the hardware specs for this device that I want to run my MATLAB code on. Please note that this device is not a computer, it is a video processing unit. I would like to ask you if there is any online simulation that I could give it my code and the hardware specs as inputs and the simulation will output for me the execution time for the code if it runs on that device?
I am looking forward to your response and thank you in advance.
Image Analyst
Image Analyst le 7 Jan 2021
Not that I know of.

Connectez-vous pour commenter.

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by