how to plot multiple images (separately) in one window
Mostrar comentarios más antiguos
Hi everyone,
I have 2304x1024 matrix. I assume that each 3 rows of this matrix describe an image.(so I have 768 images and each image size = 3x1024 ).
Let's assume that imagesc(1:3, 1024 ) gives the first image, imagesc(4:6,1024) describes the second one and so on.
My code is here :
for ind=1:768
start= (ind-1)*3+1;
stop=ind*3;
data = wholedata(start:stop,:);
imagesc(data); %%%% or pcolor(data) or %%%% I = mat2gray(data) and imshow(I)
end
When I use plot instead of imagesc I can plot multiple graphs in one figure :
figure
for ind=1:768
start= (ind-1)*3+1;
stop=ind*3;
data = wholedata(start:stop,:);
subplot(1,768,ind);
plot(data);
hold on;
end
I want to display images not graphs.
How to plot multiple images side by side in 1x768 format in a figure for example ? Or 32x24 format in a figure?
Thanks for your help.
2 comentarios
Image Analyst
el 30 de Dic. de 2020
Editada: Image Analyst
el 30 de Dic. de 2020
You aren't really going to display 768 images side by side across your display are you? Each image or plot would be only a pixel or two wide! Even if you did
subplot(28, 28, ind);
they'd still be pretty tiny!
If your screen is in a 9x16 aspect ratio, you can say (9*r) * (16*r) = 768, or r=2.3 and your subplot would look like
subplot(21, 37, ind);
Adam Danz
el 30 de Dic. de 2020
...or use tiledlayout('flow') and let Matlab arrange the plots for you. But even that has problems as I illustrated in my answer.
Respuesta aceptada
Más respuestas (1)
Adam Danz
el 29 de Dic. de 2020
768 independent axes on a figure will likely be problematicm, specifically the memory needed and the tiny size of each axis.
To demonstrate, the code below creates all 768 axes but I had to stop it after 551 axes because it was taking too long to add another axes (scroll down for more advice).
wholedata = rand(2304,1024);
nImages = size(wholedata,1)/3;
assert(mod(nImages,1)==0, 'The number of rows of data does not agree with number of images.')
data3D = reshape(wholedata',size(wholedata,2),3,[]);
fig = figure();
tlo = tiledlayout(fig,'flow','TileSpacing','compact','Padding','compact');
for i = 1:size(data3D,3)
ax = nexttile(tlo);
imagesc(ax,data3D(:,:,i)')
end

Why not keep your image data together in its original 2304x1024 array?
figure()
imagesc(wholedata)
If you want to show the border between every 3rd row,
h=arrayfun(@(y)yline(y,'w-'),.5:3:size(data,1));
but that will add a lot of lines to the image.
2 comentarios
Fatma Nur Disci
el 30 de Dic. de 2020
Adam Danz
el 30 de Dic. de 2020
I'm curious to see a screenshot of this figure, if you're willing.
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!