MATLAB GUI IMAGE PROCESSING FROM LISTBOX

2 ビュー (過去 30 日間)
MFK
MFK 2015 年 4 月 11 日
コメント済み: MFK 2015 年 4 月 12 日
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
%

採用された回答

Image Analyst
Image Analyst 2015 年 4 月 12 日
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 件のコメント
MFK
MFK 2015 年 4 月 12 日
Can you help me more please? I couldn't handle with it. Can you give me an example?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by