How do I remove the spaces between concatenated images. they are too wide but i want the image to appear as 1 after concatenation

4 views (last 30 days)
for d=c:-1:1
image = imread ( sprintf('image%d.jpg',d));
imshow(image,'parent',x)%accesible objects shown here

Answers (1)

DGM on 17 May 2022
Edited: DGM on 17 May 2022
Depending on what your needs are, you can use montage(), imtile(), or something else.
Instead of trying to display images one at a time, read them and store them in a cell array.
filenames = {'peppers.png','football.jpg','cameraman.tif','llama.jpg'};
nfiles = numel(filenames);
imstack = cell(nfiles,1);
for f = 1:nfiles
imstack{f} = imread(filenames{f});
% you could use montage()
montage(imstack); % result is 1080x1440
% or you could use imtile()
outpict = imtile(imstack); % result is 768x1024
Note that in both these cases, the images are not shown on a common scale. Depending on the size and number of your images, you may notice that they've been downscaled.
If you want to enforce a certain size, you can play with the 'thumbnailsize' parameter for either function. This is mostly useful if your images are all the same size. If they aren't the same size, you might have to make some compromises between scaling and good use of space.


Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!