Rev Author Line No. Line
178 kaklik 1 #ifndef IMAGE_CONV_H
2 #define IMAGE_CONV_H
3  
4 #include "image.h"
5 #include "multi_array_conv.h"
6  
7 namespace mimas {
8  
9 /** Correlation of two images.
10 This method provides correlation of two images. The
11 resulting image will have the same size as the input-image \c x.
12 Elements outside of the image-boundaries are assumed to be zero.
13  
14 The algorithm is intented to be used for convoluting an image with
15 a small filter. If the filter is very big, it may be more efficient, to
16 perform the correlation in fourier-space.
17  
18 @param x First array.
19 @param y Second array.
20 @return Result of correlation.
21 @see arrayOp
22 @see fourierTransforms */
23 template< typename T, typename TPtr, typename UPtr >
24 inline image< T > correlate( const const_image_ref< T, TPtr > &x,
25 const const_image_ref< T, UPtr > &y )
26 {
27 image< T > retVal; retVal.init( x.getWidth(), x.getHeight() );
28 boost::multi_array_ref< T, 2 >
29 dr( retVal.rawData(),
30 boost::extents[ retVal.getHeight() ][ retVal.getWidth() ] );
31 boost::const_multi_array_ref< T, 2 >
32 dx( x.rawData(), boost::extents[ x.getHeight() ][ x.getWidth() ] ),
33 dy( y.rawData(), boost::extents[ y.getHeight() ][ y.getWidth() ] );
34 dr = correlate( dx, dy );
35 return retVal;
36 }
37  
38 #ifdef HAVE_LIBLAPACK
39  
40 template< typename T, typename TPtr, typename UPtr >
41 image< T > correlate_separable( const const_image_ref< T, TPtr > &x,
42 const const_image_ref< T, UPtr > &f )
43 {
44 return image< T >( correlate_separable< T >( x.rawData(), f.rawData() ) );
45 }
46  
47 #endif
48  
49 }
50  
51 #endif