Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_LAPLACIAN_BLUR_H
00002 #define OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_LAPLACIAN_BLUR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/containers/grid/util/grid_poisson_solver.h>
00013
00014 #include <boost/lambda/lambda.hpp>
00015 #include <algorithm>
00016
00017 namespace OpenTissue
00018 {
00019 namespace grid
00020 {
00030 template<typename grid_type>
00031 inline void laplacian_blur(
00032 grid_type & image
00033 , double diffusion=1.0
00034 , size_t max_iterations = 10
00035 )
00036 {
00037 using std::fabs;
00038
00039 grid_type rhs = image;
00040 if(fabs(diffusion-1.0)>0.0)
00041 {
00042 double inv_diffusion = 1.0/diffusion;
00043
00044 typename grid_type::iterator r_end = rhs.end();
00045 typename grid_type::iterator r = rhs.begin();
00046 for(;r!=r_end;++r)
00047 (*r) *= inv_diffusion;
00048
00049
00050
00051
00052
00053
00054
00055 }
00056 else
00057 std::fill( rhs.begin(), rhs.end(), typename grid_type::value_type(0.0) );
00058
00059 poisson_solver(image,rhs,max_iterations);
00060 }
00061
00062 }
00063 }
00064
00065
00066 #endif