MATLAB GUI IMAGE PROCESSING FROM LISTBOX

2 visualizaciones (últimos 30 días)
MFK
MFK el 11 de Abr. de 2015
Comentada: MFK el 12 de Abr. de 2015
I have written a GUI which is using one listbox and two axes. When I click to pushbutton, I can see my folder list in listbox. And after in axes1, I can see images as preview. But I can not use this images for image processing. How can I select an image from listbox for image processeing? Sorry for my bad english.
function menuopenfolder_Callback(hObject, eventdata, handles)
% hObject handle to menuopenfolder (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
fn = uigetdir(handles.cdir,'Select directory');
if fn ~= 0
handles.cdir = fn;
img = dir(fullfile(handles.cdir,'*.bmp'));
for x = 1 : length(img)
handles.I{x} = imread(fullfile(handles.cdir,img(x).name));
end
if length(img) ~= 0, set(handles.listbox1,'enable','on');
else, set(handles.listbox1,'enable','off');
end
set(handles.text5,'string',handles.cdir);
set(handles.listbox1,'string',{img.name});
end
guidata(hObject, handles);
--------------------------------
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
handles.output = hObject;
index = get(handles.listbox1,'value');
axes(handles.axes1);
imshow(handles.I{index});
guidata(hObject, handles);
-------------------------------
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
return
%

Respuesta aceptada

Image Analyst
Image Analyst el 12 de Abr. de 2015
Get the 'string' property of the listbox to get a list of all the items in the listbox into a cell array. Then get the 'value' property and use it as an index to all the items list to give you the one(s) that are selected.
  1 comentario
MFK
MFK el 12 de Abr. de 2015
Can you help me more please? I couldn't handle with it. Can you give me an example?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps 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