bilateral.hpp
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 #ifndef PCL_FILTERS_BILATERAL_IMPL_H_
00039 #define PCL_FILTERS_BILATERAL_IMPL_H_
00040
00041 #include <pcl/filters/bilateral.h>
00042
00044 template <typename PointT> double
00045 pcl::BilateralFilter<PointT>::computePointWeight (const int pid,
00046 const std::vector<int> &indices,
00047 const std::vector<float> &distances)
00048 {
00049 double BF = 0, W = 0;
00050
00051
00052 for (size_t n_id = 0; n_id < indices.size (); ++n_id)
00053 {
00054 int id = indices[n_id];
00055
00056 double intensity_dist = fabs (input_->points[pid].intensity - input_->points[id].intensity);
00057
00058
00059 double dist = std::sqrt (distances[n_id]);
00060 double weight = kernel (dist, sigma_s_) * kernel (intensity_dist, sigma_r_);
00061
00062
00063 BF += weight * input_->points[id].intensity;
00064 W += weight;
00065 }
00066 return (BF / W);
00067 }
00068
00070 template <typename PointT> void
00071 pcl::BilateralFilter<PointT>::applyFilter (PointCloud &output)
00072 {
00073
00074 if (sigma_s_ == 0)
00075 {
00076 PCL_ERROR ("[pcl::BilateralFilter::applyFilter] Need a sigma_s value given before continuing.\n");
00077 return;
00078 }
00079
00080 if (!tree_)
00081 {
00082
00083 if (input_->isOrganized ())
00084 tree_.reset (new pcl::search::OrganizedNeighbor<PointT> ());
00085
00086 else
00087 tree_.reset (new pcl::search::KdTree<PointT> (false));
00088 }
00089 tree_->setInputCloud (input_);
00090
00091 std::vector<int> k_indices;
00092 std::vector<float> k_distances;
00093
00094
00095 output = *input_;
00096
00097
00098 for (size_t i = 0; i < indices_->size (); ++i)
00099 {
00100
00101 tree_->radiusSearch ((*indices_)[i], sigma_s_ * 2, k_indices, k_distances);
00102
00103
00104 output.points[(*indices_)[i]].intensity = computePointWeight ((*indices_)[i], k_indices, k_distances);
00105 }
00106 }
00107
00108 #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter<T>;
00109
00110 #endif // PCL_FILTERS_BILATERAL_H_
00111