Dear Image Analyst,
I checked the MAGIC gui but I do not see the required things I need. I specially need to display each step of my image processing on the listbox.
Let's say, When I load an Image, the axes1 will display the image and the listbox will show 'Image Loaded' Then I apply median filtering from menu. Then the listbox will show 'Median Filter'. The main thing I am interested is: When I select 'Median Filter' from the listbox and click 'Delete' pushbutton, the median filter step will be removed and the axes will display the loaded raw image.
Here is the gui that I am trying to make. I just don't understand how I can pass the string to the listbox and how the listbox can be interactive as I described.
function varargout = test_image_process(varargin)
% TEST_IMAGE_PROCESS MATLAB code for test_image_process.fig
% TEST_IMAGE_PROCESS, by itself, creates a new TEST_IMAGE_PROCESS or raises the existing
% singleton*.
%
% H = TEST_IMAGE_PROCESS returns the handle to a new TEST_IMAGE_PROCESS or the handle to
% the existing singleton*.
%
% TEST_IMAGE_PROCESS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TEST_IMAGE_PROCESS.M with the given input arguments.
%
% TEST_IMAGE_PROCESS('Property','Value',...) creates a new TEST_IMAGE_PROCESS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before test_image_process_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to test_image_process_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help test_image_process
% Last Modified by GUIDE v2.5 03-Aug-2018 21:34:57
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @test_image_process_OpeningFcn, ...
'gui_OutputFcn', @test_image_process_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before test_image_process is made visible.
function test_image_process_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to test_image_process (see VARARGIN)
% Choose default command line output for test_image_process
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes test_image_process wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = test_image_process_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function file_menu_Callback(hObject, eventdata, handles)
% hObject handle to file_menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function open_image_Callback(hObject, eventdata, handles)
% hObject handle to open_image (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% handles structure with handles and user data (see GUIDATA)
[fileName, pathName] = uigetfile('*.*', 'MultiSelect', 'on');
% Cancel if user hit cancel
if isequal(fileName, 0); return; end
% Make sure that fileName is a cell
if ischar(fileName); fileName = {fileName}; end
% Load all images into a cell array and store it in the handles structure
filenames = fullfile(pathName, fileName);
handles.imagedata = cellfun(@imread, filenames, 'uniformoutput', 0);
% Display the first one and store the graphics handle to the imshow object
handles.image = imshow(handles.imagedata{1}, 'Parent', handles.axes1);
guidata(hObject, handles);
% --------------------------------------------------------------------
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function image_processing_Callback(hObject, eventdata, handles)
% hObject handle to image_processing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function median_filter_Callback(hObject, eventdata, handles)
% hObject handle to median_filter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.FilterImage = arrayfun(@(k) medfilt2( handles.imagedata {k},[3,3]),1:numel(handles.imagedata ), 'UniformOutput',false);
handles.image = imshow( handles.FilterImage{1}, 'Parent', handles.axes1);
guidata(hObject, handles);
% --- Executes on button press in pushbutton_delete.
function pushbutton_delete_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_delete (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
1 Comment
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/413466-image-analysis-from-gui-with-menu-listbox-and-pushbutton#comment_596352
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/413466-image-analysis-from-gui-with-menu-listbox-and-pushbutton#comment_596352
Sign in to comment.