필터 지우기
필터 지우기

Hi I'm creating a GUI for part of an image processing project. To this point I have one push button that reads in an image (and does something with it), and another push button that will then convert that image into a binary image now how to allow

조회 수: 1 (최근 30일)
Hi I'm creating a GUI for part of an image processing project. To this point I have one push button that reads in an image (and does something with it), and another push button that will then convert that image into a binary image now how to allow the second push button function to access that image : below is the code:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick an Image File');
S = imread([pathname,filename]);
axes(handles.axes1);
imshow(S);
handles.f=[pathname,filename];
guidata(hObject, handles);
figure1.text = 'image uploaded'
% --- Executes on button press in pushbutton2.
function process_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)
if isfield(handles, 'myImage')
myImage = handles.f;
% convert to binary
binary_image=im2bw(imread('handles.f'));
%Small region is taken to show output clear
binary_image = binary_image(120:400,20:250);
figure;imshow(binary_image);title('Input image');
  댓글 수: 1
Adam
Adam 2017년 6월 23일
Please try to format your question in a readable way.
I corrected it for you this time, but the Code { } block should be used for code rather than for your text!

댓글을 달려면 로그인하십시오.

채택된 답변

Adam
Adam 2017년 6월 23일
This is an important source to read and understand when you are wanting to do anything with GUIs. There are numerous methods. Personally I mostly use the handles struct and guidata.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by