Raspberry Pi stacks collection #90 = BilinearPerspective141.livecode[Version 1.4.1 of Feb 1, 2017 -- avoid now linux ink-bug]Bilinear (quadrilateral) Image Distortion = LC-Magick #6
[By Hermann Hoch and Bernd Niggemann]
This is the LiveCode implementation of the well known bilinear distortion technique.
For each new 'distortion' the algorithm solves 8 linear equations and looks up the pixel data at the corresponding coords of the source image. The 'core' code is only at about 110 lines. Based on the description here: http://www.imagemagick.org/Usage/distorts/
* Drag the handles of the 'distortion-generating' polygon.
* Use the 'helper' buttons for flipping the image or mirroring the polygon
* Inflate or deflate the 'distortion-generating' polygon ('zoom').
* Antialias or and/or frame the distorted result.
* Copy the result or save it to a file.
* Use a text field for input, to generate distorted 'banners'.
* Use the images menu for testing with some examples.
* Import your own images into the example images menu.
The stack has help. Parts of the main scripts are commented.
Once again, the result is surprisingly fast if the targeted object is not too large. Using LC 6 (which is 2-3 times faster than LC 7/8/9 with this technique) we have on RaspberryPi 2/3 computing times around 1-2 seconds for a medium sized distorted target image, acceptable for me. (Antialiasing may double these times -- beauty has its price.)
The stack has a size that is not acceptable in the forum. So it is available (fast) via the "Sample Stacks" item of the toolbar
or (slower) at livecodeshare
.The stack runs on Mac/Win/Linux using LC 6/7/8/9, and on RaspberryPi using (the for Raspi available) LC 651 or LC 704.
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)