Skip to content

Virtual Pixels and Matte

Virtual Pixels and Tiling

The distortion mapped point may not hit the actual source image, but somewhere beside it, or even a lot way from the actual image. The solution to this is to pretend the source image surrounded by an 'infinite' or 'virtual' surface, which is defined by the current virtual pixel method setting.

This can be very useful for generating distorted, or even undistorted tile patterns of the source image.

Supported Virtual Pixel Methods

TIP

You can see effects, produced by each of virtual pixel method at ImageMagick docs.

Lens currently supports following virtual pixel methods:

  • VirtualPixelMethod.BACKGROUND: image's background color will be used as virtual pixel color.
  • VirtualPixelMethod.EDGE: Color of the nearest image edge will be used.
  • VirtualPixelMethod.TILE: Behaves like if image is infinitely tiled pattern in all directions.
  • VirtualPixelMethod.MIRROR: Similar to tile but each next tile is 'mirrored' previous tile in all directions.
  • VirtualPixelMethod.RANDOM: Use random pixel color from image.
  • VirtualPixelMethod.TRANSPARENT: Use transparent color.
  • VirtualPixelMethod.BLACK: Use black color.
  • VirtualPixelMethod.GRAY: Use gray color.
  • VirtualPixelMethod.WHITE: Use white color.
  • VirtualPixelMethod.HORIZONTAL_TILE: The image is only tiled horizontally, while the virtual pixels above and below the tiles are set from the current image's background color. Useful for full circle Arc distortion.
  • VirtualPixelMethod.HORIZONTAL_TILE_EDGE: also tiles the image horizontally across the virtual space, but replicates the side edge pixels across the other parts of the virtual canvas space.
  • VirtualPixelMethod.VERTICAL_TILE: Similarly the 'Vertical Tile' setting tiles the image vertically only, with the current background color used to fill in the sides of the image.
  • VirtualPixelMethod.VERTICAL_TILE_EDGE: Tiles image vertically and replicates the side edge pixels across the rest of the virtual canvas space.

Invalid Distortion Pixels (Matte)

Sometimes the distortion of a destination pixel does not even 'hit' the virtual tiled image! This generally happens when you distort the image using some type of 3-dimensional space distortion method and the pixel 'vector' does not even hit the source plane in which the image lies. Basically the result of the distortion becomes 'undefined' mathematically. In that case the color will be determined from the matteColor option.

For example when you see 'sky' in a Perspective Distortion, the mathematics for determining the source image location became 'undefined' (actually it is defined, but it is not valid from a users forward viewing perspective). As such the matteColor is output for the 'sky'.

Actually the perspective distortion algorithm also manages to include some 'antialiasing' information for pixels close to the horizon, though that is uncommon for such situations.