I'm looking to create another push button which will convert browse image to binary of the image I read in, I'm not sure how to define the image under the new function as the image that was chosen previously, could any one help,
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
indrani dalui
am 22 Jun. 2017
Beantwortet: indrani dalui
am 23 Jun. 2017
function process_Callback(hObject, eventdata, handles)
% hObject handle to process (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%convert binary Image
binary_image = binary_image(120:400,20:250);
figure;imshow(binary_image);title('binary image');
%Small region is taken to show output clear
binary_image = binary_image(120:400,20:250);
figure;imshow(binary_image);title('binary_image');
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 22 Jun. 2017
indrani - it sounds like you 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. If the problem is how to allow the second push button function to access that image, then what you can do is to save the image to the handles structure so that all callbacks have access to this image. For example,
function readimage_Callback(hObject, eventdata, handles)
[filename,pathname,filterindex] = uigetfile();
handles.myImage = imread(fullfile(pathname, filename));
guidata(hObject, handles);
% do other stuff if needed
Then, in your other callback, you would access this image as
function process_Callback(hObject, eventdata, handles)
if isfield(handles, 'myImage')
myImage = handles.myImage;
% convert to binary, etc.
end
In the first callback, we load the image (I'm not sure how you are doing this so the code presented here will be different). We call guidata to update the handles structure with the myImage field. In the second callback, we check for existence of the image field and then use it as needed.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Code Generation, GPU, and Third-Party Support finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!