How can I plot or place three or four figures in one figure

I have three figures size 198kb, 208kb and 187kb. How can i make those figures showing in a single panel? say the figure names are EM_SH_01, EM_SH_02,EM_SH_03

Réponses (1)

Keegan Carvalho
Keegan Carvalho le 30 Avr 2022
Modifié(e) : Keegan Carvalho le 30 Avr 2022
If I understood correctly, what you could do is use subplots. You could get your 4 images and then export them as one panel
myimage = imread('image1.jpg');
myimage2 = imread('image2.jpg');
myimage3 = imread('image3.jpg');
myimage4 = imread('image4.jpg');
subplot(2,2,1)
image("myimage")
title('EM_SH_01')
subplot(2,2,2)
image("myimage2")
title('EM_SH_02')
subplot(2,2,3)
image("myimage3")
title('EM_SH_03')
subplot(2,2,4)
image("myimage4")
title('EM_SH_04')

8 commentaires

I tried subplot. But there's a gap sustain between the images. If I could use montage, I think the problem could have been resolved. But my images are of different sizes.
Try resizing the image using imresize().
Regarding the gaps between subplots, I came across this link some time ago.
I could not understand it how to use. Better if you can help me writing the code using this function according to my problem
Show your code for using montage() or imtile().
imgNames = dir('*.jpg') ; % give your exntenion of images in the folder
N = length(imgNames) ; % toal number of images
thepath = 'E:\New Rev\figs'; % give path of the folder here
% loop for each image
for i = 1:N
thisImg = imgNames(i).name ;
I=imread(thisImg);
figure(1)
imshow(I) ;
L = imresize(I,.50,'bilinear');
figure(2)
imshow(L);
% WRite image into a folder
[filepath,name,ext] = fileparts(thisImg) ;
name = [thepath,filesep,name,'.jpg'] ;
imwrite(L,name)
end
out = montage('EM_SH1.jpg','EM_SH2.jpg','EM_SH3.jpg','EM_SH4.jpg');
The problem is that if resize it to 0.50, the actual size in kb remains different
Why are you resizing? Just call montage on the original files. If you need to resize the output, call imresize() on "out". Then call
imshow(out);
uint8, double, uint16, logical, single, int16
Instead its type was char.
Error in montage>parse_inputs (line 246)
validateattributes(varargin{1}, ...
Error in montage (line 114)
[I,cmap,mSize,indices,displayRange,parent] = parse_inputs(varargin{:});
getting this error if i use montage
myimage1 = imread('EM_SH1.jpg');
myimage2 = imread('EM_SH2.jpg');
myimage3 = imread('EM_SH3.jpg');
myimage4 = imread('EM_SH4.jpg');
% out = montage('ElNino_SH_1516DJF.jpg','ElNino_SH_8283DJF.jpg','ElNino_SH_9192DJF.jpg','El Nino_Anomaly_1997_98.jpg');
out = montage('myimage1','myimage2','myimage3','myimage4');
imshow(out);
size of the images are: 197kb, 208kb,191kb,194kb
the error I am geeting is:
uint8, double, uint16, logical, single, int16
Instead its type was char.
Error in montage>parse_inputs (line 246)
validateattributes(varargin{1}, ...
Error in montage (line 114)
[I,cmap,mSize,indices,displayRange,parent] = parse_inputs(varargin{:});

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Centre d'aide et File Exchange

Commenté :

le 30 Avr 2022

Community Treasure Hunt

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

Start Hunting!

Translated by