display multiple image in one figure window using for loop

my image database folder has images named 1.bmp,2.bmp..and so on i want to use for loop (1 to 5) and display five images in one window how to do it?

 采纳的回答

for K = 1 : 5
this_image = imread( sprintf('%d.bmp', K) );
ax = subplot(1, 5, K);
imshow(this_image, 'Parent', ax);
end

4 个评论

i have attached a picture (output of this code), but i want these 5 figures in one window
It looks to me as if somewhere you have a figure() call that you should not have. The code I posted will put everything together into one window, in a 1 x 5 arrangement.
For example,
files = {'1A.png', 'howwhathello.png', 'z_how.png', 'z_hello.png', 'plus.png'};
for K = 1 : 5; this_image = imread(files{K}); ax = subplot(1,5,K); imshow(this_image, 'Parent', ax); end
Hey Walter,
I was wondering how to save this image once its displayed. I read up on the imwrite function and tried to implement it in my code, but I was unable to do so.
Do let me know if I should ask this as a separate question.
Thank you!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by