Swirl
Image swirling is a non-linear image deformation that creates a whirlpool
effect. This example describes the implementation of this transform in
skimage, as well as the underlying warp mechanism.
Image warping
When applying a geometric transformation on an image, we typically make use of a reverse mapping, i.e., for each pixel in the output image, we compute its corresponding position in the input. The reason is that, if we were to do it the other way around (map each input pixel to its new output position), some pixels in the output may be left empty. On the other hand, each output coordinate has exactly one corresponding location in (or outside) the input image, and even if that position is non-integer, we may use interpolation to compute the corresponding image value.
Performing a reverse mapping
To perform a geometric warp in skimage, you simply need to provide the
reverse mapping to the skimage.transform.warp() function. E.g., consider
the case where we would like to shift an image 50 pixels to the left. The reverse
mapping for such a shift would be:
