How can I color the area inside the outers points?

3 vues (au cours des 30 derniers jours)
Francesco
Francesco le 25 Fév 2014
Réponse apportée : Paul le 25 Fév 2014
The simple questions is:
1) If I have the coordinates of some points How can I color the area enclosed by the outer segments?
Image, If you see the attached image you can see the situation. I have the coordinates of the points 6 11 15 and 29. I want to connect 6 with 11, 11 with 29, 29 with 15 and 15 with 6: this is the matter. Is it possibile? I have the coordinates of the points.
  1 commentaire
Image Analyst
Image Analyst le 25 Fév 2014
What do you mean by "color"? Is an image or a plot? If an image do you want to pseudocolor the image with a colormap or do you want to write the colors into an RGB image, or do you want to put something into the overlay with patch() or fill()? If a graph, do you want to use patch() or fill() to display a region in the overlay?

Connectez-vous pour commenter.

Réponse acceptée

Paul
Paul le 25 Fév 2014
x=rand(5,1);
y=rand(5,1);
center_x=mean(x);
center_y=mean(y);
[th,rho] = cart2pol(x-center_x,y-center_y);
thr=sortrows([th,rho]);
[xs,ys]=pol2cart(thr(:,1),thr(:,2));
% figure; %fill with normal x and y values
% fill(x,y,'r')
figure;
fill(xs+center_x,ys+center_y,'r')
This transforms the coordinates to polar coordinates, sorts them based on the angle around the centre and then transforms these back to cartesian coordinates.

Plus de réponses (0)

Catégories

En savoir plus sur Modify Image Colors dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by