Next | Prev | Up | Top | Contents | Index

Performing Convolution

Performing convolution consists of these steps:

  1. If desired, specify filter scale, filter bias, and convolution parameters for the convolution kernel. For example:

    glConvolutionParameteriEXT(GL_CONVOLUTION_2D_EXT,

    GL_CONVOLUTION_BORDER_MODE_EXT,

    GL_REDUCE_EXT /*nothing else supported at present */);

    glConvolutionParameterfvEXT(GL_CONVOLUTION_2D_EXT,

    GL_CONVOLUTION_FILTER_SCALE_EXT,filterscale);

    glConvolutionParameterfvEXT(GL_CONVOLUTION_2D_EXT,

    GL_CONVOLUTION_FILTER_BIAS_EXT, filterbias);

  2. Define the image to be used for the convolution kernel.

    Use a 2D array for 2D convolution and a 1D array for 1D convolution. Separable 2D filters consist of two 1D images for the row and the column.

    To specify a convolution kernel, call glConvolutionFilter2DEXT(), glConvolutionFilter1DEXT(), or glSeparableFilter2DEXT().

    The following example defines a 7 x 7 convolution kernel that is in RGB format and is based on a 7 x 7 RGB pixel array previously defined as rgbBlurImage7x7:

    glConvolutionFilter2DEXT(

    GL_CONVOLUTION_2D_EXT, /*has to be this value*/

    GL_RGB, /*filter kernel internal format*/

    7, 7, /*width & height of image pixel array*/

    GL_RGB, /*image internal format*/

    GL_FLOAT, /*type of image pixel data*/

    (const void*)rgbBlurImage7x7 /* image itself*/

    )

    For more information about the different parameters, see the reference page for the relevant function.

  3. Enable convolution.

  4. Perform pixel operations (for example pixel drawing or texture image definition).

    Convolution happens as the pixel operations are executed.

  5. Use glGetConvolutionParameter*EXT() to retrieve the following convolution state parameters:

    GL_CONVOLUTION_BORDER_MODE_EXT


    Convolution border mode. For a list of border modes, see glConvolutionParameterEXT().

    GL_CONVOLUTION_FORMAT_EXT


    Current internal format. For lists of allowable formats, see glConvolutionFilter*EXT(), and glSeparableFilter2DEXT().

    GL_CONVOLUTION_FILTER_{BIAS, SCALE}_EXT


    Current filter bias and filter scale factors. params must be a pointer to an array of four elements, which receive the red, green, blue, and alpha filter bias terms in that order.

    GL_CONVOLUTION_{WIDTH, HEIGHT}_EXT


    Current filter image width.

    GL_MAX_CONVOLUTION_{WIDTH, HEIGHT}_EXT


    Maximum acceptable filter image width and filter image height.

Next | Prev | Up | Top | Contents | Index