imresize bilinear MATLAB

妖精的绣舞 提交于 2019-12-06 13:18:44

Assume that your image is A = [ 0 1 2]; so we can visualize the structure of image pixels as

     _________ _________ _________ 
    |         |         |         |
    |    0    |    1    |    2    |
    |_________|_________|_________|

    0   0.5   1   1.5   2   2.5   3

That its x coordinates ranges from 0 to 3 and position of value of the pixel is assumed in the center of it.

When we want to resize the image to 5 pixels we should find where the values should be extracted from the original image. For it we multiply [0:5] by 3/5.

     _____ _____ _____ _____ _____ 
    |     |     |     |     |     |
    |     |     |     |     |     |
    |_____|_____|_____|_____|_____|

    0    3/5   6/5   9/5   12/5   3

To find position of center of pixels we multiply ([0:4] + .5) by 3/5

((0:4) + .5) * 3/5

ans = 
    0.3   0.9   1.5   2.1   2.7

So for example to find value of the second pixel in the scaled image we should refer to position 0.9 in the orginal imaged and extract(interpolate) value of the pixel which is 0.4.

     _____ _____ _____ _____ _____ 
    |     |     |     |     |     |
    |     | 0.4 |  1  | 1.6 |     |
    |_____|_____|_____|_____|_____|

      0.3   0.9   1.5   2.1   2.7  

Value of the first and the last pixels(and generally those pixels that have positions beyond [0.5-2.5]) are set the same as the first and the last pixels of the original image respectively .

     _____ _____ _____ _____ _____ 
    |     |     |     |     |     |       
    |  0  | 0.4 |  1  | 1.6 |  2  |
    |_____|_____|_____|_____|_____|
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!