更新时间:2023-01-18 10:16:47
在图像上绘制线条的最简单方法是使用 PLOT.
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.