I want to bend an image

9 ビュー (過去 30 日間)
Mats
Mats 2014 年 9 月 23 日
コメント済み: Mats 2014 年 9 月 24 日
Dear community,
I have this 720x720 image and want to do a spatial transform in a way that a horizontal line will become a U-shape. So depending on the x-coordinate the rotation/translation will be different. Simply put the left side should rotate a bit clockwise and the right side counterclockwise.
Any thoughts?
nParts = 15;
iWidth = size(IM,2)/nParts;
iRotation = (-(nParts-1)/2:(nParts-1)/2)*2;
for iPart = 1:nParts;
K(iPart) = {imrotate(IM(:,iPart*iWidth-
iWidth+1:iPart*iWidth),iRotation(iPart),'bilinear','loose')};
end
This is what I came up with only now the K(i) elements have to be combined, or even better solution would be a single transformation matrix, like:
x' = x*?*cos(t) + y*?*sin(t)
y' = -x*?*sin(t) + y*?*cos(t).
Kind regards,
Mats

採用された回答

Image Analyst
Image Analyst 2014 年 9 月 23 日
Sorry I don't have time this morning to fix it or complete it for you. See Steve's blog: http://blogs.mathworks.com/steve/2006/08/04/spatial-transformations-defining-and-applying-custom-transforms/ for guidance.
  1 件のコメント
Mats
Mats 2014 年 9 月 24 日
To let you know, I found the solution with your help yesterday! So it worked.
t = @(x) x(:,1).*-pi/4;
f = @(x) [x(:,1).*cos(t(x))+x(:,2).*sin(t(x)),-x(:,1).*sin(t(x))+x(:,2).*cos(t(x))];
g = @(x, unused) f(x);
tform = maketform('custom', 2, 2, [], g, []);
IM = imtransform(IM, tform, 'UData', [-1 1], 'VData', [-1 1], ...
'XData', [-1 1], 'YData', [-1 1]);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by