windowbuttondown无法读取更新的图像

时间:2015-08-11 19:11:32

标签: image matlab user-interface

最近我在MATLAB中构建了一个接口,我的目标是通过改变像素的值来修复原始的细胞分割结果。我主要依靠三个函数来完成这项工作:WindowButtonDown WindowButtonMotion WindowButtonUp,但它似乎只能实现一次,也就是说,当我第二次单击该按钮时,它只是在我添加一个单元格时忽略更新的Img并使用图像的原始版本。我不知道为什么,因为我在WindowButtonMotion函数的末尾清楚地说明了:handles.Img = Img。

这是我的代码的一部分:

function figure2_WindowButtonDownFcn(hObject, eventdata, handles)
global Mflag x0 y0 x y PaintFlag Eflag value m;

......
Img=handles.Img;
m=max(Img(:));

Mflag = 1;
......
guidata(hObject, handles);

function figure2_WindowButtonMotionFcn(hObject, eventdata, handles)
global Mflag x0 y0 x y PaintFlag Eflag value m;

......

if Mflag
 Img=handles.Img;
 .....
 if PaintFlag
    .....
    if temp1==get(handles.Add,'Max')&&temp2==get(handles.Fix,'Min')

       Color = handles.cmap(m+1,:);
       Img(xx,yy)=m+1;      
       handles.Img=Img;%when I set keyboard after this I found the updated image had been stored in handles.
    elseif temp1==get(handles.Add,'Min')&&temp2==get(handles.Fix,'Max')

       Color = handles.cmap(value,:);
       Img(xx,yy)=value;
       handles.Img=Img;
    end
  end
    ......
end
guidata(hObject, handles);

function figure2_WindowButtonUpFcn(hObject, eventdata, handles)
global Mflag;
Mflag = 0;
guidata(hObject, handles);

我无法弄清楚为什么WindowButtonDown函数无法在WindowButtonMotion中读取更新的Img,我需要在添加新单元格时逐渐增加m。但它只是继续阅读原始的。我想知道为什么以及如何解决这个问题? 谢谢你的帮助。

0 个答案:

没有答案