Convolve

Author : Melanie Rhianna Lewis
Input Type : TrianaPixelMap
Output Type : TrianaPixelMap
Date :

This Unit performs a general convolution on an image. The diagram above shows a pixel (red) and the eight others which surround it (yellow). A general convolution generates a pixel in the result image by applying defined weights to these nine pixels in the source image and taking the weighted average.

If the weights are:


    Wa, Wb, Wc, Wd, We, Wf, Wg, Wh, Wi
for the pixels A to I respectively then each pixel is generated thus:

    rr(i, j) = SUM(Wa x ra(i - 1, j - 1) + Wb x ra(i, j - 1) + ... Wi x ra(i + 1, j + 1)) / SUM(Wa + Wb + ... + Wi)
    gr(i, j) = SUM(Wa x ga(i - 1, j - 1) + Wb x ga(i, j - 1) + ... Wi x ga(i + 1, j + 1)) / SUM(Wa + Wb + ... + Wi)
    br(i, j) = SUM(Wa x ba(i - 1, j - 1) + Wb x ba(i, j - 1) + ... Wi x ba(i + 1, j + 1)) / SUM(Wa + Wb + ... + Wi)
The matrix can be defined using the Unit window.

Example

The network below uses values for Wa to Wi of -1, -1, -1, -1, 9, -1, -1, -1, -1 to carry out an edge detection.

Before operation After operation

See also

Lnb, Snb, ImageBlur