Scale X and Y separately in a matrix

조회 수: 6 (최근 30일)
S
S 2019년 7월 16일
편집: Adam 2019년 7월 17일
Hi,
I have a matrix of an image. I want to scale the x axis of the matrix by keeping y the same. (Like stretch the image only in X keeping Y the same). I'm thinking of using the aspect ratio (X/Y). But by multiplying the whole matrix by the aspect ratio doesn't give the result I want. Is there a way to do this.
Thanks
  댓글 수: 2
Adam
Adam 2019년 7월 16일
doc interp2
will allow you to change the sizes of x and y independently. Just use the same y grid for output as you did for input and choose your new x grid to be what you want.
Or just
doc imresize
should work, unless I am misunderstanding what result you are expecting.
S
S 2019년 7월 16일
In doc imresize the whole image is stretched or srink, right? Can it be used to stretch only x axis and keep y axis the same. Could you please send me an example code.
Thank you very much

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam
Adam 2019년 7월 17일
편집: Adam 2019년 7월 17일
B = imresize(A,[numrows numcols])
is the second syntax given in the documentation. If you pass in a numrows the same as the current size of A then this will remain unchanged in B, while the number of columns can change independently of this.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by