put all images of a directory in listbox

how can i put all images of a directory in listbox and then select one of them to do image to show in axes

답변 (2개)

Walter Roberson
Walter Roberson 2014년 1월 20일

0 개 추천

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
David Sanchez 2014년 1월 20일

0 개 추천

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

malek el pikho
malek el pikho 2014년 1월 20일
i put this in listbox_callback
malek el pikho
malek el pikho 2014년 1월 20일
but nothing shown
Walter Roberson
Walter Roberson 2014년 1월 20일
편집: Walter Roberson 2014년 1월 20일
It does not go in the listbox callback, it goes in the place you want to trigger the initialization of the listbox.
David, more efficient:
my_pngs = dir('*.png');
pics_cell = {my_pngs.name};
set(handles.my_list, 'String', pics_cell);
malek el pikho
malek el pikho 2014년 1월 20일
편집: malek el pikho 2014년 1월 20일
yes it's done iput a pushbuton to initialise the listbox the problem now is in set(handles.my_list, 'String', pics_cell); it show only one image in the listbox how can show all the images
malek el pikho
malek el pikho 2014년 1월 20일
images are shown in the first index only how to increment index in listbox
malek el pikho
malek el pikho 2014년 1월 20일
no no no its done thanks a lot
Image Analyst
Image Analyst 2014년 1월 20일
Then mark it as accepted.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

제품

질문:

2014년 1월 20일

댓글:

2014년 1월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by