Image Matlab:在指南中的图像上叠加绘图
在使用Matlab指南时,我希望在图像上绘制一条线。当我在GUI中只使用一个轴时,我成功地实现了这一点。但是,添加另一个轴后,绘图不再覆盖图像 最初,绘图开始在错误的轴上绘图,我意识到我忘记设置适当的轴。但是,一旦我选择了要打印的图像轴,要打印的线就不再位于图像的顶部,而只是用线的图形替换图像 我的代码:Image Matlab:在指南中的图像上叠加绘图,image,user-interface,matlab,matlab-guide,Image,User Interface,Matlab,Matlab Guide,在使用Matlab指南时,我希望在图像上绘制一条线。当我在GUI中只使用一个轴时,我成功地实现了这一点。但是,添加另一个轴后,绘图不再覆盖图像 最初,绘图开始在错误的轴上绘图,我意识到我忘记设置适当的轴。但是,一旦我选择了要打印的图像轴,要打印的线就不再位于图像的顶部,而只是用线的图形替换图像 我的代码: imshow(img(k),'Parent',handles.display) hold on x1 = line(k).point1(1); y1 = line(k).point1(2);
imshow(img(k),'Parent',handles.display)
hold on
x1 = line(k).point1(1);
y1 = line(k).point1(2);
x2 = line(k).point2(1);
y2 = line(k).point2(2);
plot(handles.display,[x1 x2],[y1 y2],'Color','r','LineWidth', 2)
hold off
添加新轴之前的代码与上面相同,但带有句柄。显示plot()的参数
任何帮助都将不胜感激,提前谢谢。调用该函数时,还需要指定轴句柄。例如:
%# create some axes
hAx1 = subplot(121);
hAx2 = subplot(122);
%# draw in first: image with line overlayed
I = imread('coins.png');
imshow(I, 'Parent',hAx1)
hold(hAx1,'on')
plot(hAx1, [1 100], [1 100], 'Color','r', 'LineWidth',2)
hold(hAx1,'off')
%# draw in second
surf(hAx2, peaks)