#include <DericheFilter.h>
Public Types | |
typedef BaseImage< DIM, Pixel > | Image |
typedef Image::Index | Index |
typedef BaseImage< DIM, float > | ImageVariance |
typedef blitz::RectDomain< DIM > | RectDomain |
Public Member Functions | |
Constructors - Destructor | |
DericheFilter (float _sigma, int _order=0, bool _border_cond=true) | |
Constructor for isotropic filter. | |
DericheFilter (float _sigma[DIM], int _order=0, bool _border_cond=true) | |
Constructor for anisotropic filter. | |
DericheFilter (ImageVariance &_sigma, int _order=0, bool _border_cond=true) | |
Constructor for space-varying filter. | |
~DericheFilter () | |
Destructor. | |
Main Methods | |
void | filter (Image &image) |
filter the image | |
void | filter_axis (Image &image, const int axis) |
filter the image in only one axis, axis begin at '1' | |
Modify/Access member data | |
void | set_filter_type (int _filter_type) |
set the type of filter : 0=isotrope; 1=anisotrope; 2=space-variant | |
void | set_order (int _order) |
set order of derivation | |
void | set_border_cond (bool _border_cond) |
set order of derivation | |
void | set_isotropic_sigma (float _sigma) |
set isotropic sigma | |
void | set_anisotropic_sigma (float _sigma[DIM]) |
set anisotropic sigma in each axis | |
void | set_image_sigma (const ImageVariance &_sigma) |
set variant sigma, represented as an image | |
Protected Member Functions | |
Internal method | |
void | _init_coefs () |
initialize the coefficient of the recursive filter | |
void | _coefs_sigma (float sigma, float coefs[6], float border_coefs[4]) |
coefficient of the recursive filter for a given sigma | |
void | _deriche_map (Image line, const int axis, Pixel *tmp_buf, Index lbound, Index ubound) |
filter one line with forward and backward passing deriche filter | |
Protected Attributes | |
Member data | |
int | m_filter_type |
type of the filter : 0=isotropic ; 1=anisotropic ; 2=space-variant | |
int | m_order |
order of derivation : 0=blur ; 1=1st derivative ; 2=2nd derivative | |
bool | m_border_cond |
border condition : true=neumann ; false=dirichlet value 0 | |
float | m_sigma [DIM] |
isotropic & anisotropic variance | |
ImageVariance * | m_sigma_image |
space-variant isotropic variance | |
float | m_coefs [6 *DIM] |
6*DIM coefficients of the isotropic & anisotropic filter | |
ImageVariance * | m_variant_coefs [6] |
6 image-coefficients of the space-variant filter | |
float | m_border_coefs [4 *DIM] |
4*DIM coefficients for the neumann border condition of the isotropic & anisotropic filter |
It's a fast recursive filter used to
you can choose 3 different type of blur :
2 border conditions :
TODO border conditions pour space-variant blur foireux
2D_Anisotropic_Blur.C, 2D_MinimalPath.C, and 2D_SpaceVariant_Blur.C.
Definition at line 43 of file DericheFilter.h.
DericheFilter | ( | float | _sigma, | |
int | _order = 0 , |
|||
bool | _border_cond = true | |||
) | [inline] |
Constructor for isotropic filter.
_sigma | variance of the isotropic filter |
_order | order of derivation |
_border_cond | border condition |
Definition at line 149 of file DericheFilter.h.
References DericheFilter::_init_coefs(), DericheFilter::m_sigma, and DericheFilter::m_variant_coefs.
00150 :m_filter_type(0), m_order(_order), m_sigma_image(NULL), m_border_cond(_border_cond) 00151 { 00152 for (int i=0 ; i<DIM; i++) 00153 m_sigma[i] = _sigma; 00154 00155 for (int i=0 ; i<6; i++) 00156 m_variant_coefs[i] = NULL; 00157 00158 _init_coefs(); 00159 }
DericheFilter | ( | float | _sigma[DIM], | |
int | _order = 0 , |
|||
bool | _border_cond = true | |||
) | [inline] |
Constructor for anisotropic filter.
_sigma | variances of the anisotropic filter |
_order | order of derivation |
_border_cond | border condition |
Definition at line 162 of file DericheFilter.h.
References DericheFilter::_init_coefs(), DericheFilter::m_sigma, and DericheFilter::m_variant_coefs.
00163 :m_filter_type(1), m_order(_order), m_sigma_image(NULL), m_border_cond(_border_cond) 00164 { 00165 for (int i=0 ; i<DIM; i++) 00166 m_sigma[i] = _sigma[i]; 00167 00168 for (int i=0 ; i<6; i++) 00169 m_variant_coefs[i] = NULL; 00170 00171 _init_coefs(); 00172 }
DericheFilter | ( | ImageVariance & | _sigma, | |
int | _order = 0 , |
|||
bool | _border_cond = true | |||
) | [inline] |
Constructor for space-varying filter.
_sigma | image containing a local variance in each pixel |
_order | order of derivation |
_border_cond | border condition |
Definition at line 175 of file DericheFilter.h.
References DericheFilter::_init_coefs(), DericheFilter::m_sigma, and DericheFilter::m_variant_coefs.
00176 :m_filter_type(2), m_order(_order), m_sigma_image(&_sigma), m_border_cond(_border_cond) 00177 { 00178 for (int i=0 ; i<DIM; i++) 00179 m_sigma[i] = 0.0; 00180 00181 for (int i=0 ; i<6; i++) 00182 m_variant_coefs[i] = NULL; 00183 00184 _init_coefs(); 00185 }
void filter_axis | ( | Image & | image, | |
const int | axis | |||
) | [inline] |
filter the image in only one axis, axis begin at '1'
SEQUENTIAL VERSION
PARALLEL VERSION
Definition at line 208 of file DericheFilter.h.
References DericheFilter::_deriche_map().
Referenced by DericheFilter::filter().
00209 { 00210 // get the first slice in the given axis 00211 Index tl = image.lbound(); 00212 Index br = image.ubound(); 00213 tl(axis) = 0; 00214 br(axis) = 0; 00215 00216 blitz::RectDomain<DIM> rect_domain(tl, br); 00217 Image slice = image(rect_domain); 00218 int ubound = image.ubound(axis-1); 00219 00220 #if 0 00221 00222 Pixel* tmp_buf = new Pixel[image.extent(axis-1)]; 00223 00224 // on each pixel of the slice, get its "perpendicular line" in the axis direction, and make a deriche filter on it 00225 for (typename Image::template iterator<domain> i=slice.begin() ; i!=slice.end() ; ++i){ 00226 rect_domain.lbound() = i.position(); 00227 rect_domain.ubound() = i.position(); 00228 rect_domain.ubound(axis-1) = ubound; 00229 00230 _deriche_map(image(rect_domain), axis, tmp_buf, rect_domain.lbound(), rect_domain.ubound()); 00231 } 00232 00233 delete[] tmp_buf; 00234 00235 #else 00236 00237 Index tmp[slice.size()]; 00238 int i = 0; 00239 for (typename Image::template iterator<domain> it=slice.begin() ; it!=slice.end() ; ++it) 00240 tmp[i++] = it.position(); 00241 00242 #pragma omp parallel 00243 { 00244 // ATTENTION un Ybuf par thread. 00245 Pixel* tmp_buf = new Pixel[image.extent(axis-1)]; 00246 #pragma omp for 00247 for (int i = 0 ; i < slice.size() ; i++){ 00248 blitz::RectDomain<DIM> rect_domain(tmp[i],tmp[i]); 00249 rect_domain.ubound(axis-1) = ubound; 00250 _deriche_map(image(rect_domain), axis, tmp_buf, rect_domain.lbound(), rect_domain.ubound()); 00251 } 00252 delete[] tmp_buf; 00253 } 00254 #endif 00255 00256 }