I want to bend an image

9 Ansichten (letzte 30 Tage)
Mats
Mats am 23 Sep. 2014
Kommentiert: Mats am 24 Sep. 2014
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

Akzeptierte Antwort

Image Analyst
Image Analyst am 23 Sep. 2014
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 Kommentar
Mats
Mats am 24 Sep. 2014
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]);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by