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 Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by