SMIL  0.11.3-dev
Convolution

2D and 3D Convolution with linear kernels More...

Detailed Description

2D and 3D Convolution with linear kernels

+ Collaboration diagram for Convolution:

Functions

template<class T >
RES_T gaussianFilter (Image< T > &imIn, int radius, Image< T > &imOut)
 gaussianFilter() - 3D Gaussian filter More...
 
template<class T >
RES_T horizConvolve (const Image< T > &imIn, const vector< double > &kernel, Image< T > &imOut)
 horizConvolve() - 2D Horizontal convolution More...
 
template<class T >
RES_T vertConvolve (const Image< T > &imIn, const vector< double > &kernel, Image< T > &imOut)
 vertConvolve() - 2D Vertical convolution More...
 
template<class T >
RES_T convolve (const Image< T > &imIn, const vector< double > &kernel, Image< T > &imOut)
 convolve() - 2D Convolution More...
 

Function Documentation

◆ gaussianFilter()

RES_T smil::gaussianFilter ( Image< T > &  imIn,
int  radius,
Image< T > &  imOut 
)

gaussianFilter() - 3D Gaussian filter

Gaussian Filter : convolution de l'input image against a Gaussian Kernel of size 2 * radius + 1

The kernel is defined, in each direction, by :

\[ k[i] = exp(- \frac{(i - radius)^2}{2}) \; , i \in [-radius, +radius] \]

Parameters
[in]imIn: input image
[in]radius: radius of the gaussian kernel
[out]imOut: output image

Example

import smilPython as sp
imIn = sp.Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
imOut = sp.Image(imIn)
imIn.show()
imOut.show()
sp.gaussianFilter(imIn, 3, imOut)

◆ horizConvolve()

RES_T smil::horizConvolve ( const Image< T > &  imIn,
const vector< double > &  kernel,
Image< T > &  imOut 
)

horizConvolve() - 2D Horizontal convolution

2D horizontal convolution using a 1D kernel

Parameters
[in]imIn: input image
[in]kernel: an 1D kernel (as a vector)
[out]imOut: output image

Example:

import smilPython as sp
im1 = sp.Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
im2 = sp.Image(im1)
kern = [ 0.0545, 0.2442, 0.4026, 0.2442, 0.0545 ]
sp.horizConvolve(im1, kern, im2)
im1.show()
im2.show()

◆ vertConvolve()

RES_T smil::vertConvolve ( const Image< T > &  imIn,
const vector< double > &  kernel,
Image< T > &  imOut 
)

vertConvolve() - 2D Vertical convolution

2D vertical convolution using a 1D kernel

Parameters
[in]imIn: input image
[in]kernel: an 1D kernel (vector)
[out]imOut: output image
See also
horizConvolve()

◆ convolve()

RES_T smil::convolve ( const Image< T > &  imIn,
const vector< double > &  kernel,
Image< T > &  imOut 
)

convolve() - 2D Convolution

2D convolution by & 1D kernel. Vertical convolution followed by an horizontal convolution using the same 1D kernel.

Parameters
[in]imIn: input image
[in]kernel: the 1D kernel (vector)
[out]imOut: output image
See also
horizConvolve()