Leaflet.DistortableImage
Leaflet.DistortableImage copied to clipboard
Tests demonstrating how `#_calculateProjectiveTransform` works
Problem
LDI allows perspectival distortions of aerial images over a flat, projected map. It is key for georectification.
Projective transformation
We correct for camera perspective distortion by using a projective transformation; specifically we calculate a 4*4 projective transformation matrix mapping each corner of the aerial photograph to a geographic coordinate on the map.
Georectification
Ultimately, this transformation allows us to neatly fit images taken from multiple perspectives into a common map coordinate system, a process called georectification.
Below is a great visual example of an image being rectified over a plane:
Set of 2D images. The original images are taken from different perspectives (row 1). Using systematic transformations (rows 2 and 3), we are able to transform both images such that corresponding points are on the same horizontal scan lines (row 4).
![]()
Since the projective transformation functionality is so core to LDI, we would like to document it better.
Solution
You can find our #_calculateProjectiveTransform method here:
https://github.com/publiclab/Leaflet.DistortableImage/blob/af4bea824707298cc47739b14c5f0d7f57228910/src/DistortableImageOverlay.js#L453-L485
You will probably want to check out L.MatrixUtil as well: https://github.com/publiclab/Leaflet.DistortableImage/blob/main/src/util/MatrixUtil.js
A shell for the test can be found here - please overrwrite this test to be useful and remove the it.skip so that it runs.
https://github.com/publiclab/Leaflet.DistortableImage/blob/af4bea824707298cc47739b14c5f0d7f57228910/test/src/DistortableImageOverlaySpec.js#L33-L44
Test whatever aspect(s) of this functionality you'd like. The goal is for it to be explanatory, as a form of documentation that might allow us to clean the comments in the function itself.
💬 Get help
If you need any help - here are some options:
- Comment below
- Join our gitter chat at https://gitter.im/publiclab/publiclab
Uploaded to GCI dashboard
Published Thanks Sasha you are super helpful