Write a Matlab function to normalise a set of image points so their mean is zero and their root mean squared distance from the origin is √2.
This was explained in the document I found as:
function [T_norm] = normalise_points(X);
% normalise_points determines the homogeneous
% transformation matrix T_norm such that
%
% X_norm = T_norm*X
%
% defines an X_norm with a mean of 0 and rms
% (root mean squared) distance from the origin
% of sqrt(2).
[T1_norm] = normalise_points(X1);
X1_norm = T1_norm*X1;
[T2_norm] = normalise_points(X2);
X2_norm = T2_norm*X2;
I have also found some Matlab code (see below), that normalises an
array of homogenous, it doesn't quite do the same function as the previous mentioned -
I don't think it achieves the mean average of 0 and of course I don't have the homogeneous transformation matrix, which I think could be useful to me later now.
Anyhelp
modifying it in so I can achieve the said function would be greatly appreciated.
% HNORMALISE - Normalises array of homogeneous coordinates to a scale of 1
%
% Usage: nx = hnormalise(x)
%
% Argument:
% x - an Nxnpts array of homogeneous coordinates.
%
% Returns:
% nx - an Nxnpts array of homogeneous coordinates rescaled so
% that the scale values nx(N,:) are all 1.
%
% Note that any homogeneous coordinates at infinity (having a scale value of
% 0) are left unchanged.
% Peter Kovesi
% School of Computer Science & Software Engineering
% The University of Western Australia
% https://www.csse.uwa.edu.au/~pk
%
% February 2004
function nx = hnormalise(x)
[rows,npts] = size(x);
nx = x;
% Find the indices of the points that are not at infinity
finiteind = find(abs(x(rows,:)) > eps);
if length(finiteind) ~= npts
warning('Some points are at infinity');
end
% Normalise points not at infinity
for r = 1:rows-1
nx(r,finiteind) = x(r,finiteind)./x(rows,finiteind);
end
nx(rows,finiteind) = 1;