如何在Matlab中的图像上画一条线? [英] How to draw a line on an image in matlab?

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

问题描述

我有两点可以说:

  • P(x,y)[点位于图像的顶部]
  • P'(x',y')[点位于图像的底部]

现在我要在这两点之间画一条线....该线应出现在图像上,意味着应该可见.

Now i want to draw a line betwen these two points....and the line should appear on image means should be visible.

该怎么做????

推荐答案

在图像上画线的最简单方法是使用

The simplest way to draw a line onto an image is to use PLOT.

%# read and display image
img = imread('autumn.tif');
figure,imshow(img)

%# make sure the image doesn't disappear if we plot something else
hold on

%# define points (in matrix coordinates)
p1 = [10,100];
p2 = [100,20];

%# plot the points.
%# Note that depending on the definition of the points,
%# you may have to swap x and y
plot([p1(2),p2(2)],[p1(1),p2(1)],'Color','r','LineWidth',2)

如果要使用其他颜色,请将字母更改为任何rgbcmykw,或使用RGB三胞胎(红色为[1 0 0]).请查看 lineseries属性了解更多格式设置选项

If you want a different color, either change the letter to any of rgbcmykw, or use RGB triplets (red is [1 0 0]). Have a look at the lineseries properties for more formatting options.

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

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