Skip to content

Commit 5da0137

Browse files
committed
compute normalization matrix for 2d points
1 parent e309a55 commit 5da0137

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

getNormMat2d.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function Nmatrix = getNormMat2d(x)
2+
% Function: Compute the normalization matrix of 2d points in
3+
% homogeneous coordinate
4+
% Normalization criteria:
5+
% 1. Move the centroidto the origin
6+
% 2. Average distance of points to the centroid is sqrt(2)
7+
%
8+
% Usage:
9+
%
10+
% Nmatrix = getNormMat(x)
11+
% where:
12+
% Nmatrix - the normalization matrix
13+
% x - input data, dim: 3xN
14+
%
15+
% Institute: Australian National University
16+
% Author: Zhen Zhang
17+
% Last modified: 11 Apr. 2018
18+
19+
% Get the centroid
20+
centroid = mean(x, 2);
21+
% Compute the distance to the centroid
22+
dist = sqrt(sum((x - repmat(centroid, 1, size(x, 2))) .^ 2, 1));
23+
% Get the mean distance
24+
mean_dist = mean(dist);
25+
% Craft normalization matrix
26+
Nmatrix = [sqrt(2) / mean_dist, 0, -sqrt(2) / mean_dist * centroid(1);...
27+
0, sqrt(2) / mean_dist, -sqrt(2) / mean_dist * centroid(2);...
28+
0, 0, 1];
29+
30+
end

0 commit comments

Comments
 (0)