Image Processing Problem (Listbox)

조회 수: 1 (최근 30일)
KHOR  WEI KOK
KHOR WEI KOK 2016년 7월 26일
편집: Image Analyst 2016년 7월 31일
I have some problem in the Matlab listbox GUI, how to select several images in listbox and display all these images in axes1, axes2, axes 3 and etc. I don't quite understand about the current images selected (I want to display certain images which I have selected). Hope there is an example to clear my mind. Thanks.

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 7월 30일
Khor - how many axes do you have and how do you decide which image to assign to which axes? Will you always select three images? If you only select two, then does that mean that only axes1 and axes2 are assigned the new image? What happens if you select more images than you have for axes?
Presumably you have a push button that will load your selected images in to your axes. Within the button callback, you could do something like the following
imageFiles = get(handles.listbox1,'String'); % list of all files from list box
selectedIdcs = get(handles.listbox1,'Value'); % indices to selected files
selectedImages = imageFiles(selectedIdcs) % list of all selected files
Now, you could just iterate over each selected image and show it in the appropriate axes as
for k=1:min(size(selectedImages,1),3)
filename = selectedImages{k};
loadedImage = imread(filename);
hAxes = handles.axes1;
if k==2
hAxes = handles.axes2;
elseif k==3
hAxes = handles.axes3;
end
image(hAxes, loadedImage);
end
The above code ensures that at most three images get loaded into the three axes.
  댓글 수: 2
KHOR  WEI KOK
KHOR WEI KOK 2016년 7월 31일
My current GUI has a listbox,a insert pushbutton, a set button,15 axes. I have a total of 24 images from a folder. After I insert this folder and display in listbox, I chose an image (let's call image10 in the middle list of the listbox) to display in one of the axes. Once I select this particular image (image10), I would like to display 'before this particular image'(which it means image3,4,5,6,7,8,9) and 'after this particular image'(which it means image11,12,13,14,15,16,17) in the rest of the axes.
Image Analyst
Image Analyst 2016년 7월 31일
편집: Image Analyst 2016년 7월 31일
Get the selection and then use setdiff() to get a list of all other indexes that do not include that index. Then loop over them displaying them wherever you want.
imageFiles = handles.listbox1.String; % list of all files from list box
selectedIndex = handles.listbox1.Value;
otherIndexes = setdiff(1:length(imageFiles), selectedIndex);
for k = otherIndexes
% Display them....

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by