struggling with shifting an image using non-integer offset

I am not sure I understand the fact that the image's resolution 1500x2000 (integer values) pixels and offset_X = -3.0314 and offset_Y = 1.2432.
How to go about shifting the image taking into account the offset?

1 件のコメント

Gustav Shen
Gustav Shen 2017 年 5 月 15 日
how did you get the non-integer offset?

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

 採用された回答

Matt J
Matt J 2013 年 5 月 12 日

0 投票

Use IMTRANSFORM, griddedInterpolant(), or INTERP2.

2 件のコメント

Alex
Alex 2013 年 5 月 12 日
Thank you for the advice. Could you please, correct the code below based on interp2. Let's say I have an image (size 971x1471) assigned to variable Im. Offset for this image is offset_X = -3.0314 and offset_Y = 1.2432. I need to get the image ImC (corrected image shifted using the offset above). After reading about interp2 I came up with the next code with MATLAB error message leaping at me. Please, guide me here.
[xx,yy] = ndgrid(1:971,1:1471);
xx = xx(:);
yy = yy(:);
xxShifted = xx + offset_X;
yyShifted = yy + offset_Y;
ImC=Im;
ImC(:) = interp2(xx,yy,Im(:),xxShifted,yyShifted);
Error using griddedInterpolant The grid vectors are not strictly monotonic increasing.
Error in interp2/makegriddedinterp (line 220) F = griddedInterpolant(varargin{:});
Error in interp2 (line 125) F = makegriddedinterp({X, Y}, V, method);
Bjorn Gustavsson
Bjorn Gustavsson 2013 年 5 月 13 日
You dont need to (:) xx, yy and Im just send them into interp2 as they are.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

質問済み:

2013 年 5 月 12 日

コメント済み:

2017 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by