"With four parameters I can fit an elephant, and with five I can make him wiggle his trunk." - John von Neumann
This repository contains a small R Shiny app that lets you interactively fit an elephant with a variable number of parameters, using a Fourier transform.
To run this application, download Posit (formerly RStudio), open global.R, install the required packages and press "Run App" on the top-right.
You can also run this on other images by specifying their path in global.R. However, the fit is always a single line. So this works best for images that can be "drawn in a single line" and with clear contrast.
The fourier
function server.R applies Fourier transform techniques to a reconstruct an image based on a vector of complex numbers that represent this image.
The DFT of a sequence of
where
The reconstructed signal from its frequency-domain representation is computed as:
where NUMBER_POINTS_TO_FIT
.
The image fancy_elephant.png is taken from https://github.com/983/Elephant.