Transformation Models
The library can be used for calculating transformation parameters using 2D Affine or Thin Plate Spline (TPS) transformations.
Install
You can install it with NPM (npm install transformation-models
) or Yarn (yarn add transformation-models
) and then:
;
Affine transformation example
Allows scaling, rotation and translation only and preserves collinearity.
; const sourcePoints = 4734563812 8602649049 4725349627 8610759665 4723443326 8616104954 4721845431 8622312598 4720159801 8603248973 4718040498 8608875072 4716553179 8620405969 4724628766 863159647 4724538865 862985748 4751688217 8617662209 4746994861 8621675591 4746480919 8608375672 4741551591 8615165917 4734308135 8616623423 4744231665 8630246732 4736133859 8630921615 4732346726 8627234144;const targetPoints = 4733708335 479703427 4724353409 487647473 4722352973 492956916 4720645585 49913377 4719298709 480047397 4717080395 48563391 4715389251 497134073 4723263059 508463146 4723204053 506723307 4750559251 495015878 4745796219 498944058 4745519337 485640022 4740470969 492340007 4733204376 493668131 4742881509 507462453 4734775168 507992948 4731055189 504239725; const affine = sourcePoints targetPoints; affine;// result is: [4732974.629, 492880.087] affine;// result is: [4734064.359, 8615839.411]
TPS transformation example
Can introduce local deformations in the data, but does not preserves collinearity.
; const sourcePoints = 4734563812 8602649049 4725349627 8610759665 4723443326 8616104954 4721845431 8622312598 4720159801 8603248973 4718040498 8608875072 4716553179 8620405969 4724628766 863159647 4724538865 862985748 4751688217 8617662209 4746994861 8621675591 4746480919 8608375672 4741551591 8615165917 4734308135 8616623423 4744231665 8630246732 4736133859 8630921615 4732346726 8627234144;const targetPoints = 4733708335 479703427 4724353409 487647473 4722352973 492956916 4720645585 49913377 4719298709 480047397 4717080395 48563391 4715389251 497134073 4723263059 508463146 4723204053 506723307 4750559251 495015878 4745796219 498944058 4745519337 485640022 4740470969 492340007 4733204376 493668131 4742881509 507462453 4734775168 507992948 4731055189 504239725; const tps = sourcePoints targetPoints; tps;// result is: [4732974.629, 492880.087] tps;// result is: [4734064.359, 8615839.411]
License
transformation-models is MIT License @ bojko108