##### Personal tools
You are here: Home estimate homography MATLAB source function

# estimate homography MATLAB source function

function H = estimate_homography(origin_x, origin_y, rotation, scale) % FeEval help function for challenge scale and rotation % generates homography matrix for image transformation % origin_x = x coordinate center of rotation (center of image) % origin_y = y coordinate center of rotation (center of image) % rotation in degree 0..360 clockwise % scale scalefactor % % EXAMPLE for 1-scalerot-1.mov: % H_funkt = estimate_homography(312, 163, 10, 0.9) % % comments and improvements please to julian@prip.tuwien.ac.at H_identity = [1.0, 0, 0; 0, 1.0, 0; 0, 0, 1.0]; H_trans = H_identity; H_scale = H_identity; H_rot = H_identity; H_trans(1,3) = -origin_x; H_trans(2,3) = -origin_y; H_scale(1,1) = scale; H_scale(2,2) = scale; H_rot(1,1) = cos(deg2rad(rotation)); H_rot(2,2) = H_rot(1,1); H_rot(1,2) = sin(deg2rad(rotation)); H_rot(2,1) = -H_rot(1,2); H = inv(H_trans) * H_scale * H_rot * H_trans; % from right to left end

estimate_homography.m — Objective-C source code, 0Kb

## File contents

```function H = estimate_homography(origin_x, origin_y, rotation, scale)
% FeEval help function for challenge scale and rotation
% generates homography matrix for image transformation
% origin_x = x coordinate center of rotation (center of image)
% origin_y = y coordinate center of rotation (center of image)
% rotation in degree 0..360 clockwise
% scale scalefactor
%
% EXAMPLE for 1-scalerot-1.mov:
% H_funkt = estimate_homography(312, 163, 10, 0.9)
%
% comments and improvements please to julian@prip.tuwien.ac.at

H_identity = [1.0, 0, 0; 0, 1.0, 0; 0, 0, 1.0];
H_trans = H_identity;
H_scale = H_identity;
H_rot = H_identity;

H_trans(1,3) = -origin_x;
H_trans(2,3) = -origin_y;

H_scale(1,1) = scale;
H_scale(2,2) = scale;