1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

photobot.Layer.pixels.convolute()

Syntax

canvas.layers[i].pixels.convolute(kernel, scale=None, offset=0)

Description

A convolution kernel is a matrix that transforms pixels. Essentially, such a matrix can be used to define custom filters, the central pixel in the matrix derives its new value from the surrounding pixels multiplied by the weights in the matrix.

The kernel parameter is a list of either 9 (3x3) or 25 (5x5) integer or floating-point numbers.

Example

A simple convolution kernel is the Gaussian blur:

kernel = [0, 1, 0,
          1, 4, 1,
          0, 1, 0]
 
import photobot
canvas = photobot.canvas(100,100)
canvas.layer("robot.jpg")
canvas.layers[1].pixels.convolute(kernel)