source: trunk/src/toolbox_calib/normalize_pixel.m @ 811

Last change on this file since 811 was 810, checked in by g7moreau, 10 years ago
  • Add license
File size: 2.1 KB
Line 
1%=======================================================================
2% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
3%   http://www.legi.grenoble-inp.fr
4%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
5%
6%     This file is part of the toolbox UVMAT.
7%
8%     UVMAT is free software; you can redistribute it and/or modify
9%     it under the terms of the GNU General Public License as published
10%     by the Free Software Foundation; either version 2 of the license,
11%     or (at your option) any later version.
12%
13%     UVMAT is distributed in the hope that it will be useful,
14%     but WITHOUT ANY WARRANTY; without even the implied warranty of
15%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16%     GNU General Public License (see LICENSE.txt) for more details.
17%=======================================================================
18
19function [xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c)
20
21%normalize
22%
23%[xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c)
24%
25%Computes the normalized coordinates xn given the pixel coordinates x_kk
26%and the intrinsic camera parameters fc, cc and kc.
27%
28%INPUT: x_kk: Feature locations on the images
29%       fc: Camera focal length
30%       cc: Principal point coordinates
31%       kc: Distortion coefficients
32%       alpha_c: Skew coefficient
33%
34%OUTPUT: xn: Normalized feature locations on the image plane (a 2XN matrix)
35%
36%Important functions called within that program:
37%
38%comp_distortion_oulu: undistort pixel coordinates.
39
40if nargin < 5,
41   alpha_c = 0;
42   if nargin < 4;
43      kc = [0;0;0;0;0];
44      if nargin < 3;
45         cc = [0;0];
46         if nargin < 2,
47            fc = [1;1];
48         end;
49      end;
50   end;
51end;
52
53
54% First: Subtract principal point, and divide by the focal length:
55x_distort = [(x_kk(1,:) - cc(1))/fc(1);(x_kk(2,:) - cc(2))/fc(2)];
56
57% Second: undo skew
58x_distort(1,:) = x_distort(1,:) - alpha_c * x_distort(2,:);
59
60if norm(kc) ~= 0,
61        % Third: Compensate for lens distortion:
62        xn = comp_distortion_oulu(x_distort,kc);
63else
64   xn = x_distort;
65end;
Note: See TracBrowser for help on using the repository browser.