Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab - Display two images with original dimensions in the same window

Tags:

matlab

I have two grayscale images, I1 of size (w1,h1), and I2 of size (w2,h2). I would like Matlab to display them in the same figure, like this:

figure;
subplot(2,1,1), imshow(I1);
subplot(2,1,2), imshow(I2);

This code makes the images to be resized in order to be displayed with the same width.

I would like to keep the images in their original sizes (each pixel of each image takes one pixel on the screen). Is there any option I can pass to subplot or imshow to do this ?

like image 831
carlito Avatar asked Oct 23 '22 07:10

carlito


2 Answers

Use truesize:

figure
subplot(2,1,1), imshow(I1)
subplot(2,1,2), imshow(I2)
truesize

You will get a warning if it doesn't fit on the screen. Like:

Warning: Image is too big to fit on screen; displaying at 66% scale.

Edit: It worked for me because the two images I used had the same size. Apparently the general case doesn't work.

like image 124
Simon Avatar answered Nov 02 '22 11:11

Simon


Try this:

figure;
subplot(2,1,1), imshow(I1); axis equal;
subplot(2,1,2), imshow(I2); axis equal;

You could also try using axis image.

http://www.mathworks.com/help/matlab/ref/axis.html

like image 40
aganders3 Avatar answered Nov 02 '22 10:11

aganders3