Tag Archives: transformer

Image transformer

When I discovered I could manipulate images with PHP one of the first things I wanted to do was perform coordinate transformations. They have fascinated me since I first came across them and so I developed this project to satifsy my curiosity about what a skyline might look like when transformed into polar coordinates.

Links

Live page
GitHub repository

Overview

This project takes an image and uses PHP to manipulate it pixel by pixel so that the \((x,y)\) coordinates get translated into \((r,\theta\) coordinates.

Challenges

Challenge: The transformation itself isn’t trivial.
Solution: The first difficulty to overcome is the transformation itself. The details are given on the page, so I won’t reproduce them here. (Resolved)
Challenge: The transformation has to be performed “backwards”.
Solution: It took me a while to realise that the transformation has to be performed from target to source rather than the other way around. Rather than taking a pixel from source to the target, the pixel must be taken from the target to the source, because otherwise the target image will have “gaps” in it. (Resolved)

Sample input and output

An image before the transformation
An image before the transformation
An image after the transformation
An image after the transformation