⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 normalize_transform.m

📁 This is a computer vision project implemented in matlab to remove radial distortion from the image
💻 M
字号:
function [newpts, T] = normalize_transform( pts )
%   % Transform taking x's centroid to the origin
%   Ttrans = [ 1 0  0 -mean( x(:,1) ) ; 0 1 0 -mean( x(:,2) ) ; 0 0 1  -mean( x(:,3)); 0 0 0 1];
%   % Calculate appropriate scaling factor
%   x = (Ttrans * x')';
%   lengths = sqrt( sum( x(:,1:3).^2 ));
%   s = sqrt(2) / mean(lengths);
%   % Transform scaling x to an average length of sqrt(2)
%   Tscale = [ s 0 0 0; 0 s 0 0 ; 0 0 s 0; 0 0 0 1 ];
%   % Compose the transforms
%   T = Tscale * Ttrans;
%   x = T*x';
%   x = x';
centroid = sum(pts(:,1:3)) / size(pts,1)
diff = pts(:,1:3) - repmat(centroid,size(pts,1),1);
avgdist = sum(sqrt(diff(:,1).^2 + diff( :,2).^2+ diff( :,3).^2)) / size(pts,1);
scale = sqrt(3) / avgdist;
T = diag([scale scale scale 1]) * [eye(4,3) [-centroid 1]'];
newpts = pts;
newpts(:,4) = 1;
newpts = newpts * T';
newpts = newpts ./ repmat( newpts(:,4), 1, 4);
% newpts(:,4) = []; this is not required
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -