matlab gui问题 我知道如何读取图片,却不知道怎么对读取的这个图片进行处理,不知道图片是如何传递的
比如我想在按钮2中对刚才读取的图片进行处理,该怎么做啊functionpushbutton1_Callback(hObject,eventdata,handles)%hO...
比如我想在按钮2中对刚才读取的图片进行处理,该怎么做啊
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fname, pname, index] = uigetfile({'*.jpg'; '*.bmp'}, '选择图片');%读取图片
str3 = [pname fname];
axes(handles.axes1);
imshow(str3);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) 展开
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fname, pname, index] = uigetfile({'*.jpg'; '*.bmp'}, '选择图片');%读取图片
str3 = [pname fname];
axes(handles.axes1);
imshow(str3);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) 展开
展开全部
可以这样做:
function pushbutton1_Callback(hObject, eventdata, handles)
[fname, pname, index] = uigetfile({'*.jpg'; '*.bmp'}, '选择图片');%读取图片
str3 = [pname fname];
axes(handles.axes1);
imshow(str3);
handles.img = str3 %将图片赋值于句柄
guidata(hObject, handles);%更新句柄
function pushbutton2_Callback(hObject, eventdata, handles)
img1 = handles.img; %将图片赋给img1,就可以对img1进行操作了
function pushbutton1_Callback(hObject, eventdata, handles)
[fname, pname, index] = uigetfile({'*.jpg'; '*.bmp'}, '选择图片');%读取图片
str3 = [pname fname];
axes(handles.axes1);
imshow(str3);
handles.img = str3 %将图片赋值于句柄
guidata(hObject, handles);%更新句柄
function pushbutton2_Callback(hObject, eventdata, handles)
img1 = handles.img; %将图片赋给img1,就可以对img1进行操作了
追问
我试了一下,但还是提示出错了
function pushbutton2_Callback(hObject, eventdata, handles)
img1 = handles.img; %将图片赋给img1,就可以对img1进行操作了
axes(handles.axes2);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询