[英]Matlab: Superimposing a plot on an image in GUIDE
在使用Matlab的GUIDE時,我希望在圖像上畫一條線。 當我只在GUI中使用一個軸時,我設法實現了這一點。 但是,添加另一個軸后,繪圖將不再覆蓋圖像。
最初,繪圖開始在錯誤的軸上進行繪圖,我意識到我忘記了設置合適的軸。 但是,一旦選擇了要繪制的圖像軸,將要繪制的線就不再位於圖像的頂部,而是僅將圖像替換為該線的圖形。
我的代碼:
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()
的handles.display
參數。
任何幫助將不勝感激,在此先感謝您。
調用HOLD函數時,還需要指定軸手柄。 例:
%# 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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.