1

我正在开发一个能够显示与后者图像相关联的图像和数据的 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;

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

4

1 回答 1

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');

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

于 2013-06-11T09:22:59.607 回答