How do I make my circle display in pink and background in white color?

4 ビュー (過去 30 日間)
marsmar
marsmar 2022 年 11 月 28 日
コメント済み: KSSV 2022 年 11 月 28 日
This is my code at the moment. I'm trying to generate a circle in a 500x500 pixel spectrum with a fixed radius. I want to export all the circles created as images. I don't know how to make my circle display in pink or the background to be in white.
%parameteres
shape = [500 500]; % [y x]
shapecolor = [1 0.3 0.5];
backgroundcolor = [100 100 100];
% set up some things
numimges = 1;
archive = 'circulorosa';
nameofdatabase = 'cuadrado';
for k = 1:numberimages
radius = 5;
center = (shape-2*r-1).*rand(1,2)+1+r; % (y,x);
viscircles(center,r,'Color','b');
axis square;
end
Unrecognized function or variable 'numberimages'.

採用された回答

KSSV
KSSV 2022 年 11 月 28 日
[m,n] = deal(500) ; % side of image
I = ones(m,n,3) ; % initialize image with white background
% GEt cirlce on the image
[X,Y] = meshgrid(1:n,1:m) ;
C = [mean(X(:)) mean(Y(:))] ;
th = linspace(0,2*pi)' ;
R = 5 ;
x = C(1)+R*cos(th) ;
y = C(2)+R*sin(th) ;
idx = knnsearch([X(:) Y(:)],[x y]) ;
% Give pink color to circle pixels on image
c = [255,192,203]/255; % pick RGB color ocde
for i = 1:3
T = I(:,:,i) ;
T(idx) = c(i) ;
I(:,:,i) = T ;
end
imshow(I)
  5 件のコメント
marsmar
marsmar 2022 年 11 月 28 日
Thank you! If i wanted to change the angle or the central postion where the circle is at? How could I do that? Or what functions?
KSSV
KSSV 2022 年 11 月 28 日
Check C, this is the cneter of circle.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 11 月 28 日
You never assigned numberimages, only numimges which is spelled differently. Try
numberimages = 20; % Or whatever you want.

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by