 |
Shiokaze Framework
A research-oriented fluid solver for computer graphics
|
|
Go to the documentation of this file.
25 #ifndef SHKZ_ARRAY_GAUSSIANBLUR2_H
26 #define SHKZ_ARRAY_GAUSSIANBLUR2_H
49 int rs = std::ceil(r * 2.57);
50 std::vector<double> exp_w(2*rs+1);
51 for(
int q=-rs; q<rs+1; q++) {
52 exp_w[q+rs] = std::exp(-(q*q)/(2.0*r*r))/std::sqrt(M_PI*2.0*r*r);
54 auto valid = [&](
int i,
int j ) {
55 if( ! mask )
return true;
57 return (*mask)(mask->shape().clamp(i,j)) != 0;
62 for(
int dim : DIMS2 ) {
67 for(
int q=-rs; q<rs+1; q++) {
68 int ni = i+(dim==0)*q;
69 int nj = j+(dim==1)*q;
70 const double &wght = exp_w[q+rs];
72 T value = save()(save->shape().clamp(ni,nj));
73 val += value * wght; wsum += wght;
76 if( wsum ) result.
set(i,j, val / wsum );
void gaussian_blur(const array2< T > &array, array2< T > &result, double r, const bitarray2 *mask=nullptr)
Perform gaussian blur on grids.
Definition: array_gaussianblur2.h:48
void set(int i, int j, const T &value)
Set value on grid.
Definition: array2.h:518
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
void parallel_all(std::function< void(iterator &it)> func)
Loop over all the cells in parallel.
Definition: array2.h:1130
Namespace that performs gaussian blur.
Definition: array_gaussianblur2.h:37
Storage class that enables sharing pre-allocated arrays.
Definition: shared_array2.h:40
Two dimensional array class designed to be defined as instance member in recursive_configurable class...
Definition: array2.h:42
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
Two dimensional bit grid class designed to be defined as instance member in recursive_configurable cl...
Definition: bitarray2.h:43