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

3 次查看(过去 30 天)
a='C:\Users\rutat\OneDrive\Documents\MATLAB'
b=dir(fullfile(a,'*.jpg'))
c=numel(b)
for d=c:-1:1
image = imread ( sprintf('image%d.jpg',d));
x=subplot(1,c,d)
imshow(image,'parent',x)%accesible objects shown here
end

回答(1 个)

DGM
DGM 2022-5-17
编辑:DGM 2022-5-17
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});
end
% you could use montage()
montage(imstack); % result is 1080x1440
% or you could use imtile()
figure
outpict = imtile(imstack); % result is 768x1024
imshow(outpict)
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.

类别

Help CenterFile Exchange 中查找有关 Agriculture 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by