I want to bend an image

9 visualizaciones (últimos 30 días)
Mats
Mats el 23 de Sept. de 2014
Comentada: Mats el 24 de Sept. de 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

Respuesta aceptada

Image Analyst
Image Analyst el 23 de Sept. de 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 comentario
Mats
Mats el 24 de Sept. de 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]);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by