Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2009-2012, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id$ 00037 * 00038 */ 00039 00040 00041 #ifndef PCL_SURFACE_BILATERAL_UPSAMPLING_H_ 00042 #define PCL_SURFACE_BILATERAL_UPSAMPLING_H_ 00043 00044 #include <pcl/surface/processing.h> 00045 00046 namespace pcl 00047 { 00048 00049 /** \brief Bilateral filtering implementation, based on the following paper: 00050 * * Kopf, Johannes and Cohen, Michael F. and Lischinski, Dani and Uyttendaele, Matt - Joint Bilateral Upsampling, 00051 * * ACM Transations in Graphics, July 2007 00052 * 00053 * Takes in a colored organized point cloud (i.e. PointXYZRGB or PointXYZRGBA), that might contain nan values for the 00054 * depth information, and it will return an upsampled version of this cloud, based on the formula: 00055 * \f[ 00056 * \tilde{S}_p = \frac{1}{k_p} \sum_{q_d \in \Omega} {S_{q_d} f(||p_d - q_d|| g(||\tilde{I}_p-\tilde{I}_q||}) 00057 * \f] 00058 * 00059 * where S is the depth image, I is the RGB image and f and g are Gaussian functions centered at 0 and with 00060 * standard deviations \f$\sigma_{color}\f$ and \f$\sigma_{depth}\f$ 00061 */ 00062 template <typename PointInT, typename PointOutT> 00063 class BilateralUpsampling: public CloudSurfaceProcessing<PointInT, PointOutT> 00064 { 00065 public: 00066 typedef boost::shared_ptr<BilateralUpsampling<PointInT, PointOutT> > Ptr; 00067 typedef boost::shared_ptr<const BilateralUpsampling<PointInT, PointOutT> > ConstPtr; 00068 00069 using PCLBase<PointInT>::input_; 00070 using PCLBase<PointInT>::indices_; 00071 using PCLBase<PointInT>::initCompute; 00072 using PCLBase<PointInT>::deinitCompute; 00073 using CloudSurfaceProcessing<PointInT, PointOutT>::process; 00074 00075 typedef pcl::PointCloud<PointOutT> PointCloudOut; 00076 00077 Eigen::Matrix3f KinectVGAProjectionMatrix, KinectSXGAProjectionMatrix; 00078 00079 /** \brief Constructor. */ 00080 BilateralUpsampling () 00081 : KinectVGAProjectionMatrix () 00082 , KinectSXGAProjectionMatrix () 00083 , window_size_ (5) 00084 , sigma_color_ (15.0f) 00085 , sigma_depth_ (0.5f) 00086 , projection_matrix_ () 00087 , unprojection_matrix_ () 00088 { 00089 KinectVGAProjectionMatrix << 525.0f, 0.0f, 320.0f, 00090 0.0f, 525.0f, 240.0f, 00091 0.0f, 0.0f, 1.0f; 00092 KinectSXGAProjectionMatrix << 1050.0f, 0.0f, 640.0f, 00093 0.0f, 1050.0f, 480.0f, 00094 0.0f, 0.0f, 1.0f; 00095 }; 00096 00097 /** \brief Method that sets the window size for the filter 00098 * \param[in] window_size the given window size 00099 */ 00100 inline void 00101 setWindowSize (int window_size) { window_size_ = window_size; } 00102 00103 /** \brief Returns the filter window size */ 00104 inline int 00105 getWindowSize () const { return (window_size_); } 00106 00107 /** \brief Method that sets the sigma color parameter 00108 * \param[in] sigma_color the new value to be set 00109 */ 00110 inline void 00111 setSigmaColor (const float &sigma_color) { sigma_color_ = sigma_color; } 00112 00113 /** \brief Returns the current sigma color value */ 00114 inline float 00115 getSigmaColor () const { return (sigma_color_); } 00116 00117 /** \brief Method that sets the sigma depth parameter 00118 * \param[in] sigma_depth the new value to be set 00119 */ 00120 inline void 00121 setSigmaDepth (const float &sigma_depth) { sigma_depth_ = sigma_depth; } 00122 00123 /** \brief Returns the current sigma depth value */ 00124 inline float 00125 getSigmaDepth () const { return (sigma_depth_); } 00126 00127 /** \brief Method that sets the projection matrix to be used when unprojecting the points in the depth image 00128 * back to (x,y,z) positions. 00129 * \note There are 2 matrices already set in the class, used for the 2 modes available for the Kinect. They 00130 * are tuned to be the same as the ones in the OpenNiGrabber 00131 * \param[in] projection_matrix the new projection matrix to be set */ 00132 inline void 00133 setProjectionMatrix (const Eigen::Matrix3f &projection_matrix) { projection_matrix_ = projection_matrix; } 00134 00135 /** \brief Returns the current projection matrix */ 00136 inline Eigen::Matrix3f 00137 getProjectionMatrix () const { return (projection_matrix_); } 00138 00139 /** \brief Method that does the actual processing on the input cloud. 00140 * \param[out] output the container of the resulting upsampled cloud */ 00141 void 00142 process (pcl::PointCloud<PointOutT> &output); 00143 00144 protected: 00145 void 00146 performProcessing (pcl::PointCloud<PointOutT> &output); 00147 00148 private: 00149 int window_size_; 00150 float sigma_color_, sigma_depth_; 00151 Eigen::Matrix3f projection_matrix_, unprojection_matrix_; 00152 00153 public: 00154 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00155 }; 00156 } 00157 00158 #endif /* PCL_SURFACE_BILATERAL_UPSAMPLING_H_ */