0

I have two small images.

When I run the code below, my images are displayed in a larger size. I mean images are displayed with fit sub plots. I just want to display my small images original size not fitted size.

figure,subplot(121);imshow(IM1);
subplot(122);imshow(IM2);

I tryed axis image and truesize but failed.

Is there any way to do this?

ffttyy
  • 853
  • 2
  • 19
  • 49

1 Answers1

3

The following sets the size of the axis the figure is shown in to the number of pixels in the original image...

Note: this will stop the axis from automatically resizing with the figure window

Hax = subplot(2,2,4);
imshow('image.bmp');

[x,y] = size(imread('image.bmp'));
set(Hax,'units','pixel');
pos = get(Hax,'position');
pos(3:4) = [y,x];

set(Hax,'position',pos)

The image will start in the bottom left of where the subplot axis was previously to make it appear in the center add the following line just before pos(3:4) = [y,x];

pos(1:2) = ceil([pos(1)+pos(3)/2-y/2,pos(2)+pos(4)/2-x/2])
RTL
  • 3,577
  • 15
  • 24