Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 在matlab GUI中输入GIN后更新img_Image_Matlab_Button_User Interface_Refresh - Fatal编程技术网

Image 在matlab GUI中输入GIN后更新img

Image 在matlab GUI中输入GIN后更新img,image,matlab,button,user-interface,refresh,Image,Matlab,Button,User Interface,Refresh,我现在正在matlab上做一个小接口,我有一个问题。 基本上,我有一个图像和两个按钮,第一个是旋转图像(用ginput(2))取两个坐标),第二个是裁剪图像(也取两个坐标) 当我有2X和2Y时,我想更新我的图像 因此,我在此声明我的形象: function projetGUI_OpeningFcn(hObject, eventdata, handles, varargin) % Choose default command line output for projetGUI handles.o

我现在正在matlab上做一个小接口,我有一个问题。 基本上,我有一个图像和两个按钮,第一个是旋转图像(用
ginput(2)
)取两个坐标),第二个是裁剪图像(也取两个坐标)

当我有2X和2Y时,我想更新我的图像

因此,我在此声明我的形象:

function projetGUI_OpeningFcn(hObject, eventdata, handles, varargin)

% Choose default command line output for projetGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
axes(handles.axes1);
img = imread('plaque3.png');
imshow(img)
这是我的第一个按钮:

function pushbutton1_Callback(hObject, eventdata, handles)

[x,y] =ginput(2);

angleRad = atan((y(2)-y(1))/(x(2)-x(1)));
angleDeg = radtodeg(angleRad);

img = imrotate(img, angleDeg);
imshow(img);
set (handles.text1, 'String' ,'Résults ') ;
这是我的第二个按钮:

function pushbutton2_Callback(hObject, eventdata, handles)

[xcrop,ycrop] = ginput(2);

largeur = xcrop(2) - xcrop(1);
hauteur = ycrop(2) - ycrop(1);

img = imcrop(img,[xcrop(1) ycrop(1) largeur hauteur]);
imshow(img);
set (handles.text1, 'String' ,'Results ') ;
这就是我得到的错误:

Undefined function or variable "img".

Error in projetGUI>pushbutton1_Callback (line 91)
img = imrotate(img, angleDeg);

Error in gui_mainfcn (line 96)
        feval(varargin{:});

Error in projetGUI (line 43)
    gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)projetGUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating uicontrol Callback
我很确定出现了这个问题,因为我的图像不是一个全局变量,但我没有找到正确的方法来声明它

有人能帮我吗

非常感谢
(顺便说一句,对不起我的英语,它不是我的母语)

pushbutton1\u回调
pushbutton2\u回调
projetGUI\u OpeningFcn
的嵌套函数吗?如果不是,则是,
img
仅存在于
projetGUI\u OpeningFcn
的工作区中,而不存在于其他两个功能的工作区中

一种可能的解决方法是在
projetGUI\u OpeningFcn
guidata(hObject,handles)中使用
handles.img而不是
img
。然后,图像将由其他函数作为
handles.img
访问

有关更多信息,请参阅