Plot a circle of Gaussian varying intensity

16 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2020-6-12
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 个评论
Image Analyst
Image Analyst 2020-6-30
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 2020-7-2
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 ?

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2020-7-2
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 个评论
reham elnabawy
reham elnabawy 2021-1-7
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by