Filter löschen
Filter löschen

Read an image from an axes and write it in a listbox Matlab

2 Ansichten (letzte 30 Tage)
alladin
alladin am 26 Jan. 2015
Kommentiert: alladin am 26 Jan. 2015
I have a list box that return a list of images' names contained an a folder that i select. once i click on one of the names, i get the image displayed in an axes.
what i exactly want to do is when i click on a button called Select Image; the name of the image displayed in the axes will be written in a second list box that i have.
Does anyone have hints on how to do that?

Akzeptierte Antwort

Image Analyst
Image Analyst am 26 Jan. 2015
Try this snippet in your Select Image callback.:
% Get image name
Selected = get(handles.lstImageList, 'value');
numberOfFilesSelected = length(Selected);
% If more than one is selected, bail out.
if numberOfFilesSelected > 1
return;
end
% If only one is selected, display it.
ListOfImageNames = get(handles.lstImageList, 'string');
baseImageFileName = char(ListOfImageNames(Selected));
fullImageFileName = fullfile(handles.imageFolder, baseImageFileName); % Prepend folder.
% Put into second listbox
set(handles.listbox2, 'String', {baseImageFileName});
I think it's better to just have that in the listbox callback though. Why force them to click on the image name in the listbox and then click a button rather than have it just display immediately?
  4 Kommentare
alladin
alladin am 26 Jan. 2015
Actually i want my axes to display only one image selected from the listbox1 (which is already fine in my example).
I can select many images to be displayed in my axes.
So, that's why i can select more than one image to be displayed in my listbox2(which is not possible for now since it will rest the listbox2 to the new value)
alladin
alladin am 26 Jan. 2015
I figured it out. I have created a vector, and whenever i select one of the images, i push it to the vector, and like that i could see all the images selected.
Thank you very much for your help

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by