Mapping - Serabe/rinzelight GitHub Wiki

Theory

Map methods apply a function to every pixel in an image. Ther are two maps by now:

  • map-pixel-location: applies f to each pixel coordinates and places the pixel in the result location.
  • map-image: applies f to each pixel and writes the result in the same location.

Unlike effects, whose first parameter is the image, maps’ first parameter is the function, in order to resemble map function.

Practice

map-pixel-location

map-pixel-location accepts two parameters: a function and an image. If it is supplied four, the third and fourth are taken as the new size of the image.

If you are want to work with map-pixel-location take a look at rinzelight.effects.helper-functions. You can find functions for rotating and flipping. Usually, map-pixel-location when used with helper-functions is faster than the affine transformation (just by a few ms).

A second function can be supplied in ordert to calculate the new size.

Example

rotate-left and rotate-left-new-size helper functions are used.

map-image

map-image applies a function f to each pixel in an image. Then it writes in the same location the pixel returned by f.

This map is really slow by now, but I am trying to get it working faster.

Example

The following is the result of (map-image invert-pixel img) where img is our well known photo of the northern lights.

⚠️ **GitHub.com Fallback** ⚠️