sav_gol_smoothing_filter.hpp
Go to the documentation of this file.
00001 
00059 #ifndef SAV_GOL_SMOOTHING_FILTER_HPP_
00060 #define SAV_GOL_SMOOTHING_FILTER_HPP_
00061 
00062 
00063 #include <cob_3d_mapping_tools/sav_gol_smoothing_filter.h>
00064 
00065 template <typename PointInT, typename PointOutT> bool
00066 SavGolSmoothingFilter<PointInT,PointOutT>::smoothPoint(int index, float &z)
00067 {
00068   int idx_x = index % input_->width;
00069   int idx_y = index / input_->width;
00070   int i = 0, miss = 0;
00071 
00072   float z_i;
00073   double sum = 0.0;
00074   float limit = 0.4 * size_ * size_;
00075 
00076   for (int y = idx_y - r_; y <= idx_y + r_; y++)
00077   {
00078     for (int x = idx_x - r_; x <= idx_x + r_; x++)
00079     {
00080       z_i = input_->at(x,y).z;
00081       if (pcl_isnan((float)z_i) || std::fabs(z_i-input_->points[index].z) > high_th_) 
00082       {
00083         z_i = input_->points[index].z;
00084         miss++;
00085         if (miss > limit) return false;
00086       }
00087       
00088       sum += coef_[i] * z_i;
00089       i++;
00090     }
00091   }
00092   //std::cout << "old: " << z << " new: " << sum << std::endl;
00093   z = sum;
00094   return true;
00095 }
00096 
00097 template <typename PointInT, typename PointOutT> void
00098 SavGolSmoothingFilter<PointInT,PointOutT>::reconstruct(PointCloudOut &output, std::vector<size_t> &ignored_indices)
00099 {
00100   output = *input_;
00101   int idx = 0;
00102   
00103   for (int y = r_+1; y < input_->height - r_; y++)
00104   {
00105     for (int x = r_+1; x < input_->width - r_; x++)
00106     {
00107       idx = y*input_->width + x;
00108       if (pcl_isnan(input_->at(x,y).z))
00109         continue;
00110       if ( !smoothPoint(idx, output.points[(size_t)idx].z) )
00111       {
00112         ignored_indices.push_back((size_t)idx);
00113       }
00114     }
00115   }
00116   return;
00117 }
00118 
00119 template <typename PointInT, typename PointOutT> void
00120 SavGolSmoothingFilter<PointInT,PointOutT>::reconstruct2ndPass(
00121   std::vector<size_t> &indices, PointCloudOut &output)
00122 {
00123   std::vector<size_t>::iterator it;
00124 
00125   for (it = indices.begin(); it != indices.end(); it++)
00126   {
00127     smoothPoint(*it, output.points[*it].z);
00128   }
00129   return;
00130 }
00131 
00132 #endif // SAV_GOL_SMOOTHING_FILTER_HPP_


cob_3d_mapping_tools
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:27