フィルターのクリア

Plot a circle of desired intensity.

1 回表示 (過去 30 日間)
Jose Aroca
Jose Aroca 2020 年 6 月 11 日
コメント済み: Image Analyst 2020 年 6 月 12 日
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 件のコメント
darova
darova 2020 年 6 月 12 日
Do you know how to draw a circle?

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2020 年 6 月 12 日
Adapt as needed (center location, radius, intensity, etc.).
  2 件のコメント
Jose Aroca
Jose Aroca 2020 年 6 月 12 日
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 2020 年 6 月 12 日
See my attached demo. Adapt as needed.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by