put all images of a directory in listbox
Afficher commentaires plus anciens
how can i put all images of a directory in listbox and then select one of them to do image to show in axes
Réponses (2)
Walter Roberson
le 20 Jan 2014
will give you information on getting the image names. Once you have them in a cell string array, you can set() the listbox String property to that cell string array.
In the callback for the listbox,
choices = get(hObject, 'String');
selected = get(hObject, 'Value');
thischoice = choices{selected};
David Sanchez
le 20 Jan 2014
my_pngs = dir('*.png'); % choose png files from directory
pics_cell = cell(numel(my_pngs),1);
for k=1:numel(my_pngs)
pics_cell{k} = my_pngs(k).name;
end
set(handles.my_list,'String',pics_cell) % my_list is the name of your listbox
8 commentaires
malek el pikho
le 20 Jan 2014
malek el pikho
le 20 Jan 2014
Walter Roberson
le 20 Jan 2014
Modifié(e) : Walter Roberson
le 20 Jan 2014
It does not go in the listbox callback, it goes in the place you want to trigger the initialization of the listbox.
Walter Roberson
le 20 Jan 2014
David, more efficient:
my_pngs = dir('*.png');
pics_cell = {my_pngs.name};
set(handles.my_list, 'String', pics_cell);
malek el pikho
le 20 Jan 2014
Modifié(e) : malek el pikho
le 20 Jan 2014
malek el pikho
le 20 Jan 2014
malek el pikho
le 20 Jan 2014
Image Analyst
le 20 Jan 2014
Then mark it as accepted.
Catégories
En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!