Code covered by the BSD License  

Highlights from
translate_cog

image thumbnail

translate_cog

by

 

translation of centre of gravity of a 2d image to the origin.

translate_cog(pts)
function [ trans_mat ] = translate_cog(pts)
%2D translation of centre of gravity to te origin
%   pts is the matrix representing the 2D shape or an image. It translates the shape's centre of gravity to its origin.
%trans_mat represnts the translated matrix of the input matrix pts.
x=pts(:,1);
y=pts(:,2);
centroid=[mean(x),mean(y)];
offset=-centroid;
tx=x+offset(1);
ty=y+offset(2);
trans_mat=[tx,ty];
   
end

Contact us