如何在matlab中显示图像上的点? [英] how to show points on image in matlab?

查看:1199
本文介绍了如何在matlab中显示图像上的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些像素点,比如说p1(1,1)和p2(1,10).......

我想以任何颜色在图像上显示这些点. 该怎么做?

解决方案

MATLAB plot 文档非常全面.

LineSpec 属性列出了不同样式的线条,颜色的语法和点.

如果需要更多选项,请参见 LineSeries属性. 您可以指定诸如Marker(样式),MarkerEdgeColorMarkerFaceColorMarkerSize的属性.

您还可以使用 RGB三胞胎定义颜色(如果要偏离rgbcmykw).

示例:

用橙色的五点星形标记绘制单个点(3,4):

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

绘制带有绿色"o"标记的点数组:

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

编辑:如果您已将所有点存储为p1=[x1,y1]p2=[x2,y2]等,请首先尝试将它们重新组织为2xN矩阵.重新生成点,或者如果您已经将它们成对,请使用

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

或者,如果您有成对的成对存储的大量点,比如说不超过p1000,则您可以 使用 解决方案

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

这篇关于如何在matlab中显示图像上的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆