How to change the width of an image without changing the height

1 回表示 (過去 30 日間)
Ripul Dutt
Ripul Dutt 2017 年 6 月 7 日
コメント済み: Ripul Dutt 2017 年 6 月 8 日
Somehow my current code in MATLAB won't work, a part of which requires me to change the width of a transformed image by given amount keeping the height constant, can anyone help with it ? thanks!
load('ruler2.txt');
load('rulertran2.txt');
x=ruler2(1:52,1);
y=ruler2(1:52,2);
xtran=rulertran2(1:52,1);
ytran=rulertran2(1:52,2);
Tform=cp2tform([x y],[xtran ytran],'projective');
im=imread('TDB_17_1_Subside_1171.jpg');
imshow(im)
^^ first I wrote the above to do a pixel coordinate transformation on my image, however it needs a little more improvement so I need to decrease the width of this transformed image and below is what I did but I am not certain if that's the right way to do it, I know resize function won't work for just width or height :(
xim=imtransform(im,Tform);
im=imread('xim');
info=iminfo('xim');
hoyde=info.height;
bredde=info.width;
nyhoyde=hoyde;
nybredde=bredde/10;
[nyhoyde, nybredde, kanaler]=size(im);

採用された回答

Image Analyst
Image Analyst 2017 年 6 月 7 日
Try this:
[rows, columns, numberOfColorChannels] = size(yourImage);
newImage = imresize(yourImage, [rows, newColumns]);
  1 件のコメント
Ripul Dutt
Ripul Dutt 2017 年 6 月 8 日
Thanks so much man, this thing worked, looks like my new product won't piss off my advisor!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by