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 visualización (últimos 30 días)
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 comentario
Adam
Adam el 23 de Jun. de 2017
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!

Iniciar sesión para comentar.

Respuesta aceptada

Adam
Adam el 23 de Jun. de 2017
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.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by