Moving image by vector

I have a movie that is unstable. Moves up and down. I shared it on frames.I made binarization ,found the center of gravity of each frame. I need to set all the centers of gravity like the first one. I made : the center of gravity of the first - the center of gravity (2...x) and the result was a vector by witch a move next frame. Unfortunately, point of gravity of second and next is steal not the same as 1.Please help, I do not know solve this problem.
T = maketform('affine', [1 0 0; 0 1 0; min max 1]);
img2 = imtransform(L3, T, ...
'XData',[1 size(L3,2)], 'YData',[1 size(L3,1)]);
subplot(121), imshow(L3), axis on
subplot(122), imshow(img2), axis on

Respuestas (1)

Image Analyst
Image Analyst el 4 de En. de 2015
Editada: Image Analyst el 4 de En. de 2015

0 votos

Use the displacement field input argument of imwarp().
Try this to shift the image in x and y using the values of -64 and -302 for example:
fontSize = 20;
grayImage = imread('concordorthophoto.png');
[rows, columns, numberOfColorChannels] = size(grayImage);
subplot(1, 2, 1);
imshow(grayImage);
axis on;
title('Original Image', 'fontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
deltaX = 64; % Shift x by 64 pixels.
deltaY = 302; % Shift y by 302 pixels.
D = zeros(rows, columns, 2);
D(:,:,1) = -deltaX; % Shift x by 64 pixels.
D(:,:,2) = -deltaY; % Shift x by 302 pixels.
warpedImage = imwarp(grayImage, D);
subplot(1, 2, 2);
imshow(warpedImage);
axis on;
title('Shifted Image', 'fontSize', fontSize);

2 comentarios

Justyna
Justyna el 4 de En. de 2015
it does not work: <I have this error:
Error using imwarp Expected tform to be one of these types:
images.geotrans.internal.GeometricTransformation
Instead its type was double.
Image Analyst
Image Analyst el 4 de En. de 2015
What version of MATLAB do you have? Is it some antique version? Is so, please upgrade. What does this say
ver
which -all imwarp
whos grayImage
whos D
Did you modify my demo at all? Because it runs just fine for me.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing and Computer Vision en Centro de ayuda y File Exchange.

Preguntada:

el 4 de En. de 2015

Comentada:

el 4 de En. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by