Gaussian blur and Gauss gradient

Methods for blurring images with a gauss-bell and gauss-gradient. More...

Functions

template<typename T>
std::deque< T > mimas::gaussBlurFilter (T sigma, T maxError=(T)(1.0/256.0))
 Compute gauss-bell.
template<typename T>
boost::multi_array< T, 2 > mimas::gaussBlur (const boost::const_multi_array_ref< T, 2 > &x, T sigma, T maxError)
 Blur 2-D array.
template<typename T>
image< T > mimas::gaussBlur (const image< T > &x, T sigma, T maxError=(T)(1.0/256.0))
 Blur image.
template<typename T>
std::deque< T > mimas::gaussGradientFilter (T sigma, T maxError=(T)(1.0/256.0))
 Compute gauss-gradient.
template<typename T>
boost::multi_array< T, 2 > mimas::gaussGradientX (const boost::const_multi_array_ref< T, 2 > &x, T sigma, T maxError)
 Take x-gradient of 2-D array.
template<typename T>
image< T > mimas::gaussGradientX (const image< T > &x, T sigma, T maxError=(T)(1.0/256.0))
 Take x-gradient of 2-D image.
template<typename T>
boost::multi_array< T, 2 > mimas::gaussGradientY (const boost::const_multi_array_ref< T, 2 > &x, T sigma, T maxError)
 Take y-gradient of 2-D array.
template<typename T>
image< T > mimas::gaussGradientY (const image< T > &x, T sigma, T maxError=(T)(1.0/256.0))
 Take y-gradient of 2-D image.
template<typename T>
image< T > mimas::gaussGradientSqr (const image< T > &im, T sigma, T maxError=(T)(1.0/256.0))
 Square of gradient-norm.
template<typename T>
image< T > mimas::gaussGradientNorm (const image< T > &im, T sigma, T maxError=(T)(1.0/256.0))
 Gradient-norm.

Detailed Description

Methods for blurring images with a gauss-bell and gauss-gradient.

The filter-parameter $\sigma$ can be choosen and the size of the filter is computed by choosing an upper bound for the approximation-error.

The following example demonstrates how to blur an image:

//
// stumeikle
// canny (with postprocessing) example
//

#include <fstream>
#include <GL/glut.h>
#include <iostream>
#include <vector>
#include "image.h"
#include "image_fileinput.h"
#include "image_mesaoutput.h"
#include "rgba.h"
#include "property_image.h"
#include "gauss.h"

using namespace std;
using namespace mimas;

int main(int argc, char **argv)
{
  int retVal = 0;
  try {

    // Initialise GLUT.
    glutInit( &argc, argv );

    MMERROR( argc == 2, mimasexception, ,
             "Syntax: " << argv[0] << " <image-file>" );

    image< unsigned char > input;
    x11_display display;
    image_mesaoutput< unsigned char > window( &display );

    
    ifstream file( argv[1], ios::binary );
    MMERROR( file >> input, mimasexception, , "Error loading file \""
             << argv[1] << "\"." );

    window << input << mimas::delay( 3000 )
           << image< unsigned char >( gaussBlur< float >
                                      ( input, 10.0f, 4.0f / 256.0f ) )
           << mimas::wait( 3000 );

  } catch ( exception &e ) {
    cerr << e.what() << endl;
    retVal = 1;
  };
  return retVal;
}

Author:
Stuart Meikle (stu@stumeikle.org)

Jan Wedekind (jan at wedesoft.de)

Date:
Fri Apr 07 18:52:00 2006

Function Documentation

template<typename T>
image< T > mimas::gaussBlur ( const image< T > &  x,
sigma,
maxError = (T)( 1.0 / 256.0 ) 
)

Blur image.

Perform gaussian blur on 2-D image.

Parameters:
x Input image.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussBlurFilter

Definition at line 57 of file gauss.h.

References mimas::const_image_ref< T, T * >::getHeight(), mimas::const_image_ref< T, T * >::getWidth(), and mimas::image_ref< T >::rawData().

Here is the call graph for this function:

template<typename T>
boost::multi_array< T, 2 > mimas::gaussBlur ( const boost::const_multi_array_ref< T, 2 > &  x,
sigma,
maxError 
)

Blur 2-D array.

Perform gaussian blur on 2-D array.

Parameters:
x Input array.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussBlurFilter

template<typename T>
std::deque< T > mimas::gaussBlurFilter ( sigma,
maxError = (T)(1.0/256.0) 
)

Compute gauss-bell.

The values of the cells are computed by using differences of the integral of the gauss-function: $\displaystyle\int_{-r}^{+r}{\frac{1}{\sqrt{2\,\pi}\,\sigma}\,e^{-\displaystyle\frac{x^2}{2\,\sigma^2}}\,\mathrm{d}x}\ =\ \mathrm{erf}(\displaystyle\frac{r}{\sqrt{2}\,\sigma})$

The coefficients are normalised afterwards such that the sum of all elements of the filter is $1$.

Parameters:
sigma Standard deviation of gauss-distribution.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussBlur

template<typename T>
std::deque< T > mimas::gaussGradientFilter ( sigma,
maxError = (T)(1.0/256.0) 
)

Compute gauss-gradient.

The values of the cells are computed by using differences of the integral (the gauss-function): $\frac{1}{\sqrt{2\,\pi}\,\sigma}\,e^{-\displaystyle\frac{x^2}{2\,\sigma^2}}\,\mathrm{d}x\big\|_r^\infty$

The coefficients are normalised afterwards such that the sum of the square of all elements of the filter is $1$.

Parameters:
sigma Standard deviation of gauss-distribution.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussBlur

template<typename T>
image< T > mimas::gaussGradientNorm ( const image< T > &  im,
sigma,
maxError = (T)( 1.0 / 256.0 ) 
)

Gradient-norm.

Compute gradient-norm for 2-D image

Parameters:
im Input image.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussGradientFilter

Definition at line 148 of file gauss.h.

References mimas::gaussGradientSqr().

Here is the call graph for this function:

template<typename T>
image< T > mimas::gaussGradientSqr ( const image< T > &  im,
sigma,
maxError = (T)( 1.0 / 256.0 ) 
)

Square of gradient-norm.

Compute square of gradient-norm for 2-D image

Parameters:
im Input image.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussGradientFilter

Definition at line 132 of file gauss.h.

References mimas::gaussGradientX(), and mimas::gaussGradientY().

Referenced by mimas::gaussGradientNorm().

Here is the call graph for this function:

template<typename T>
image< T > mimas::gaussGradientX ( const image< T > &  x,
sigma,
maxError = (T)(1.0/256.0) 
)

Take x-gradient of 2-D image.

Compute gauss-gradient of 2-D image in x-direction.

Parameters:
x Input image.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussGradientFilter

template<typename T>
boost::multi_array< T, 2 > mimas::gaussGradientX ( const boost::const_multi_array_ref< T, 2 > &  x,
sigma,
maxError 
)

Take x-gradient of 2-D array.

Compute gauss-gradient of 2-D array in x-direction.

Parameters:
x Input array.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussGradientFilter

Referenced by mimas::gaussGradientSqr().

template<typename T>
image< T > mimas::gaussGradientY ( const image< T > &  x,
sigma,
maxError = (T)(1.0/256.0) 
)

Take y-gradient of 2-D image.

Compute gauss-gradient of 2-D image in y-direction.

Parameters:
x Input image.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussGradientFilter

template<typename T>
boost::multi_array< T, 2 > mimas::gaussGradientY ( const boost::const_multi_array_ref< T, 2 > &  x,
sigma,
maxError 
)

Take y-gradient of 2-D array.

Compute gauss-gradient of 2-D array in y-direction.

Parameters:
x Input array.
sigma Standard deviation.
maxError Maximum error boundary (relative to range of pixel-values).
See also:
gaussGradientFilter

Referenced by mimas::gaussGradientSqr().


[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:20 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...