在GUI matlab上绘制一个轴上的图像(.tif)和轮廓

时间:2013-06-10 09:00:46

标签: matlab matlab-guide

我正在开发一个能够显示与后一个图像相关的图像和数据的GUI。

我有一个x,y图像和一个函数f(x,y)(它是一个轮廓),我想用一个轴对象在一个单独的图中显示图像和轮廓。

这就是我在轴上显示图像的方式:

function aff_toto_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin

imshow(handles.im_ref,'parent',handles.axes1);

现在我得到一个轮廓矩阵:

[handles.c,handles.h] = contour(handles.coor_y,handles.coor_x,handles.fun,handles.vec_iso);

我想在图像本身上绘制这些轮廓线,handles.axes1.是否有人有线索?

感谢大家阅读本文。

编辑: 现在我只是想在我的照片上画一些随机的正弦曲线。我试过了

imagesc(handles.im_ref,'parent',handles.axes1);

hold(handles.axes1,'on');
plot(handles.axes1,handles.coor_x,sin(handles.coor_x));
hold off;

显示图片,但情节仍然不可见。

1 个答案:

答案 0 :(得分:0)

我最终发现了问题所在。使用gui对象时,hold函数必须以不同的方式使用。如下所示,您可以指定对象保持是否正常工作。 contour函数也是如此。可以声明Parent属性(可以是轴)。

function aff_toto_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin

imagesc(handles.im_ref,'parent',handles.axes1);

hold(handles.axes1,'on');
set(handles.axes1,'color','none');

[handles.c,handles.h] = contour(handles.coor_y,handles.coor_x,handles.ch_tr,handles.vec_iso,'Parent',handles.axes1);
hold(handles.axes1,'off');

使用此代码,我能够解决我的问题。另请参阅this page,以便找到有关在随机图片上绘制随机曲线问题的更多信息(例如,图像翻转问题在那里讨论)。

相关问题