Guide Multiple Axes to display images

4 ビュー (過去 30 日間)
Irene Anthi
Irene Anthi 2015 年 4 月 20 日
回答済み: Robert Cumming 2015 年 4 月 20 日
Hi,
so I have a guide that has 10 axes. I also have a button to load images from directory. (using dir)
I need to plot these images into the axes I have already designed in GUIDE.
I have written a loop but it doesn't work as it should. If I choose more than 4 images it will plot just the 1st in 4 different axes and so on.
I have something like this:
srcFiles = dir('*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = srcFiles(i).name;
I = imread(filename);
hAxes = finobj(gcf, 'type' ,'axes');
axes(handles.axes1);
imshow(I);
end
I would appreciate your reply.

回答 (1 件)

Robert Cumming
Robert Cumming 2015 年 4 月 20 日
You find all the axes objects but do nothing with them...
I guess you want:
rcFiles = dir('*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = srcFiles(i).name;
I = imread(filename);
% Build the handles variable for the axes name dynamically
axesName = sprintf('axes%d',i));
%Get the handle to the axes
ax = handles.(axesname)
% Explicitly tell imshow which axes to plot it.
imshow(I, 'Parent', ax);
end

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by