How to block image sizes in MATLAB

So, I have this matrix in MATLAB, the width is 200 x 600. It represents an image 2 cm x 6 cm wide. How can I build this image so that it is locked to the correct dimensions, i.e. 2 cm x 6 cm? If I use the image or imagesc commands, it stretches all the shapes and shows the wrong size. Is there a way to block it by showing an image where the x and y axes are proportional?

Secondly, I need to set this image in a 640x480 frame (20-pixel black edge on the left and right, 280 pixels - black edge at the bottom). Is there any way to do this?

+5
source share
3 answers

, axis equal axis image.

:

  • axis equal , . x, y- z x, y z.

  • axis image , , `

:

third_dimension_size=1; %# for b&w images, use 3 for rgb
framed_image=squeeze(zeros(640,480,third_dimension_size));
framed_image(20:20+600-1,140:140+200-1)= my_600_200_image;

imagesc(framed_image'); axis image;
+10

set(gca,'DataAspectRatio',[1 1 1])

:

new_image = zeros(480,640);
new_image(20:(200+20-1),20:(600+20-1)) = old_image;
+2

:

 set(gca, 'Units', 'centimeters', 'Position', [1 1 6 2])

, , .

:

new_image = zeros(480,640, size(old_image));
new_image(20:(200+20-1),20:(600+20-1),:) = old_image;
+2

All Articles