tags:

views:

73

answers:

2

i have some pixel points lets say p1(1,1) and p2(1,10).......and so on

i want to display these points on image in any color. how to do this?

+2  A: 

You can just use plot:

plot(p1(1), p1(2), 'ko');  % Small circle point in black.
plot(p1(1), p1(2), 'r.');  % Small dot in red.
Peter
Don't forget to `hold on` the image first.
eakbas
but i want to display all points i-e p1,p2,p3..... on image.
chee
A: 

MATLAB plot documentation is pretty comprehensive.

LineSpec properties lists the syntax for different styles of lines, colors, and points.

If you want more options, see LineSeries Properties. You can specify properties such as Marker (style), MarkerEdgeColor, MarkerFaceColor, and MarkerSize.

You can also use RGB triplets to define color, if you want to deviate from rgbcmykw.

Examples:

Plot a single point (3,4) with an orange five-pointed star marker:

p=[3,4];
plot(p(1),p(2),'Marker','p','Color',[.88 .48 0],'MarkerSize',20)

Plot an array of points with green 'o' markers:

p=round(10*rand(2,10));
plot(p(1,:),p(2,:),'go')

EDIT: If you've got all your points stored as p1=[x1,y1], p2=[x2,y2], etc., try reorganizing them into a 2xN matrix first. Either re-generate the points, or if you've already got them as single pairs, use

p=[p1;p2;p3]'; %# the [;] notation vertically concatenates into Nx2, 
               %# and the ' transposes to a 2xN
plot(p(1,:),p(2,:),'go')

Or, if you have a ton of points stored as single pairs, say up to p1000 or so, you could use eval (cringe).

p=[]; %# initialize p
for n=1:nPoints %# if you've got 1000 points, nPairs should be 1000
eval(['p(:,n)=p',num2str(n)],''); %#executes p(:,n)=pn' for each nPoint
end
Doresoom
but i want to display all points i-e p1,p2,p3..... on image.this displays one point only :o
chee
Are you storing individual points as `p1=(x1,y1)`, `p2=(x2,y2)`, etc.? Don't do that. MATLAB is made for working with matrices. Store your points in a 2xN matrix and use the plot array of points option in my answer.
Doresoom
Feel free to upvote my answer if it solved your problem.
Doresoom
but this eval is not displaying points on image .what to do now? :(
chee
@chee: Read my entire answer. The last line before the **EDIT** will plot your points after they're in the correct format. (The format you put them in using eval.)
Doresoom

related questions