Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_FILTERS_BILATERAL_IMPL_H_
00041 #define PCL_FILTERS_BILATERAL_IMPL_H_
00042
00043 #include <pcl/filters/bilateral.h>
00044
00046 template <typename PointT> double
00047 pcl::BilateralFilter<PointT>::computePointWeight (const int pid,
00048 const std::vector<int> &indices,
00049 const std::vector<float> &distances)
00050 {
00051 double BF = 0, W = 0;
00052
00053
00054 for (size_t n_id = 0; n_id < indices.size (); ++n_id)
00055 {
00056 int id = indices[n_id];
00057
00058 double intensity_dist = fabs (input_->points[pid].intensity - input_->points[id].intensity);
00059
00060
00061 double dist = std::sqrt (distances[n_id]);
00062 double weight = kernel (dist, sigma_s_) * kernel (intensity_dist, sigma_r_);
00063
00064
00065 BF += weight * input_->points[id].intensity;
00066 W += weight;
00067 }
00068 return (BF / W);
00069 }
00070
00072 template <typename PointT> void
00073 pcl::BilateralFilter<PointT>::applyFilter (PointCloud &output)
00074 {
00075
00076 if (sigma_s_ == 0)
00077 {
00078 PCL_ERROR ("[pcl::BilateralFilter::applyFilter] Need a sigma_s value given before continuing.\n");
00079 return;
00080 }
00081
00082 if (!tree_)
00083 {
00084
00085 if (input_->isOrganized ())
00086 tree_.reset (new pcl::search::OrganizedNeighbor<PointT> ());
00087
00088 else
00089 tree_.reset (new pcl::search::KdTree<PointT> (false));
00090 }
00091 tree_->setInputCloud (input_);
00092
00093 std::vector<int> k_indices;
00094 std::vector<float> k_distances;
00095
00096
00097 output = *input_;
00098
00099
00100 for (size_t i = 0; i < indices_->size (); ++i)
00101 {
00102
00103 tree_->radiusSearch ((*indices_)[i], sigma_s_ * 2, k_indices, k_distances);
00104
00105
00106 output.points[(*indices_)[i]].intensity = static_cast<float> (computePointWeight ((*indices_)[i], k_indices, k_distances));
00107 }
00108 }
00109
00110 #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter<T>;
00111
00112 #endif // PCL_FILTERS_BILATERAL_H_
00113