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?
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.
Use image, hold on and plot.
base_points = [142.3125,93.4375; 169.4375,176.0625];
image(fixed); colormap(gray(256)); axis image;
hold on;
plot(base_points(:,1),base_points(:,2),'go');
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