MATLAB: Display an image in Its Original Size

后端 未结 6 936
别那么骄傲
别那么骄傲 2020-12-19 05:39

Can we show an image in its original size in MATLAB?

Right now when we are showing, it is exactly fitted to the image window size. However, I want to show the image

6条回答
  •  执笔经年
    2020-12-19 06:10

    There are 3 things to take care of in order to display image in its original size (1:1):

    • The figure size and units.
    • The axes size and units.
    • The axes data aspect ratio.

    Once all of that are set according to the image size even using MATLAB's image() function one could generate 1:1 display of an image.

    Here is the sample code:

    %% Load Data
    
    mI = imread('7572939538_04e373d8f4_z.jpg');
    
    numRows = size(mI, 1);
    numCols = size(mI, 2);
    
    
    %% Setings
    
    horMargin = 30;
    verMargin = 60; %

    The result (Based on the image - Landscape by Roman Vanur):

    The full code in my Stack Overflow Q1427602 Github Repository.

提交回复
热议问题