-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalize_pixel.m
47 lines (41 loc) · 1.14 KB
/
normalize_pixel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function [xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c)
%normalize
%
%[xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c)
%
%Computes the normalized coordinates xn given the pixel coordinates x_kk
%and the intrinsic camera parameters fc, cc and kc.
%
%INPUT: x_kk: Feature locations on the images
% fc: Camera focal length
% cc: Principal point coordinates
% kc: Distortion coefficients
% alpha_c: Skew coefficient
%
%OUTPUT: xn: Normalized feature locations on the image plane (a 2XN matrix)
%
%Important functions called within that program:
%
%comp_distortion_oulu: undistort pixel coordinates.
if nargin < 5,
alpha_c = 0;
if nargin < 4;
kc = [0;0;0;0;0];
if nargin < 3;
cc = [0;0];
if nargin < 2,
fc = [1;1];
end;
end;
end;
end;
% First: Subtract principal point, and divide by the focal length:
x_distort = [(x_kk(1,:) - cc(1))/fc(1);(x_kk(2,:) - cc(2))/fc(2)];
% Second: undo skew
x_distort(1,:) = x_distort(1,:) - alpha_c * x_distort(2,:);
if norm(kc) ~= 0,
% Third: Compensate for lens distortion:
xn = comp_distortion_oulu(x_distort,kc);
else
xn = x_distort;
end;