How can I draw a special circle separated by two colors?

1 visualizzazione (ultimi 30 giorni)
Hi all.. I knew how to draw a complete circle separated by two color through asking question as following.
c=1+2j % circle centre
r=4 % radius
x=real(c)-r:0.01:real(c)+r
y1=sqrt(r^2-(x-real(c)).^2)+imag(c)
plot(x,y1,'r')
hold on
plot(x,-y1+2*imag(c),'b')
axis square
Ultimately, I am planning to draw two colored circles (including gray, white) of following picture.
Which code can I use to draw special circle?
I'd like to accept advice or idea from many people as far as possible.

Risposte (1)

Image Analyst
Image Analyst il 26 Ott 2012
I'd do it in Photoshop and then just read it in as an image. Why do it the hard way like trying to recreate it via MATLAB? You haven't said if any of your parameters will change from run to run, so I'm assuming that they won't and they'll just use the constant values you gave, like radius = 4, etc. If any of them need to change on a run-by-run basis you should have / would have said so. So that's why I say to use Photoshop (or GIMP or Paint).
  4 Commenti
Haksun Lee
Haksun Lee il 26 Ott 2012
Yes.. the rest of image was already constructed and read in as an image.
I have only to draw the gray and white arcs.
I can't draw arcs shape colored gray and white, but I tried seeing the samples given in the FAQ.
I have sample to draw special circle as following. At this code, I have serious problem because of 'for' sentence. Whenever data is changed, 'for' sentence is executed so program slows as updated data. How can I draw the special circle without 'for' sentence.
axes('units','pixels','pos',[56 165 280 300]);
x=[128 137 137 128 128];
y=[5 5 -5 -5 5];
for t=0:1:data_update
arm=fill(x,y,[0.5 0.5 0.5],'LineStyle','none');
angle=1.29*pi-0.00528*pi*t;
rot=[cos(angle) -sin(angle); sin(angle) cos(angle)];
updatecoordinate=rot*[x;y];
updateX=updatecoordinate(1,:);
updateY=updatecoordinate(2,:);
set(arm,'Xdata', updateX, 'Ydata', updateY);
end
Image Analyst
Image Analyst il 26 Ott 2012
try doing the inner and outer arcs then using poly2mask to get a binary image of the center of the arc filled in. Then apply the mask to the image
arcImage = poly2mask(coords, rows, columns);
grayImage(arcImage) = 200; % or whatever value the color gray is.
or something like that.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by