00001 #ifndef GAUSS_H 00002 #define GAUSS_H 00003 00004 #include <boost/multi_array.hpp> 00005 #include <cassert> 00006 #include <cmath> 00007 #include <deque> 00008 #include "image.h" 00009 #include "image_conv.h" 00010 #include "image_op.h" 00011 00012 namespace mimas { 00013 00037 template< typename T > 00038 std::deque< T > gaussBlurFilter( T sigma, T maxError = (T)( 1.0 / 256.0 ) ); 00039 00046 template< typename T > 00047 boost::multi_array< T, 2 > gaussBlur 00048 ( const boost::const_multi_array_ref< T, 2 > &x, T sigma, T maxError ); 00049 00056 template< typename T > 00057 image< T > gaussBlur( const image< T > &x, T sigma, 00058 T maxError = (T)( 1.0 / 256.0 ) ) 00059 { 00060 boost::const_multi_array_ref< T, 2 > data 00061 ( x.rawData(), boost::extents[ x.getHeight() ][ x.getWidth() ] ); 00062 image< T > retVal; retVal.init( x.getWidth(), x.getHeight() ); 00063 boost::multi_array_ref< T, 2 > 00064 ( retVal.rawData(), 00065 boost::extents[ retVal.getHeight() ][ retVal.getWidth() ] ) = 00066 gaussBlur< T >( data, sigma, maxError ); 00067 return retVal; 00068 } 00069 00081 template< typename T > 00082 std::deque< T > gaussGradientFilter( T sigma, 00083 T maxError = (T)( 1.0 / 256.0 ) ); 00084 00091 template< typename T > 00092 boost::multi_array< T, 2 > gaussGradientX 00093 ( const boost::const_multi_array_ref< T, 2 > &x, T sigma, T maxError ); 00094 00101 template< typename T > 00102 image< T > gaussGradientX( const image< T > &x, T sigma, 00103 T maxError = (T)( 1.0 / 256.0 ) ); 00104 00111 template< typename T > 00112 boost::multi_array< T, 2 > gaussGradientY 00113 ( const boost::const_multi_array_ref< T, 2 > &x, T sigma, T maxError ); 00114 00121 template< typename T > 00122 image< T > gaussGradientY( const image< T > &x, T sigma, 00123 T maxError = (T)( 1.0 / 256.0 ) ); 00124 00131 template< typename T > 00132 image< T > gaussGradientSqr( const image< T > &im, T sigma, 00133 T maxError = (T)( 1.0 / 256.0 ) ) 00134 { 00135 image< T > 00136 gradX( gaussGradientX( im, sigma, maxError ) ), 00137 gradY( gaussGradientY( im, sigma, maxError ) ); 00138 return sumSquares( gradX, gradY ); 00139 } 00140 00147 template< typename T > 00148 image< T > gaussGradientNorm( const image< T > &im, T sigma, 00149 T maxError = (T)( 1.0 / 256.0 ) ) 00150 { 00151 return squareRoot( gaussGradientSqr( im, sigma, maxError ) ); 00152 } 00153 00155 00156 }; 00157 00158 #include "gauss.tcc" 00159 00160 #endif