Point Cloud Library (PCL)
1.12.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
surface
bilateral_upsampling.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2009-2012, Willow Garage, Inc.
6
*
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
*
13
* * Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* * Neither the name of Willow Garage, Inc. nor the names of its
20
* contributors may be used to endorse or promote products derived
21
* from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*
36
* $Id$
37
*
38
*/
39
40
#pragma once
41
42
#include <
pcl/memory.h
>
43
#include <
pcl/pcl_macros.h
>
44
#include <pcl/surface/processing.h>
45
46
namespace
pcl
47
{
48
49
/** \brief Bilateral filtering implementation, based on the following paper:
50
* * Kopf, Johannes and Cohen, Michael F. and Lischinski, Dani and Uyttendaele, Matt - Joint Bilateral Upsampling,
51
* * ACM Transactions in Graphics, July 2007
52
*
53
* Takes in a colored organized point cloud (i.e. PointXYZRGB or PointXYZRGBA), that might contain nan values for the
54
* depth information, and it will return an upsampled version of this cloud, based on the formula:
55
* \f[
56
* \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||})
57
* \f]
58
*
59
* where S is the depth image, I is the RGB image and f and g are Gaussian functions centered at 0 and with
60
* standard deviations \f$\sigma_{color}\f$ and \f$\sigma_{depth}\f$
61
*/
62
template
<
typename
Po
int
InT,
typename
Po
int
OutT>
63
class
BilateralUpsampling
:
public
CloudSurfaceProcessing
<PointInT, PointOutT>
64
{
65
public
:
66
typedef
shared_ptr<BilateralUpsampling<PointInT, PointOutT> >
Ptr
;
67
typedef
shared_ptr<const BilateralUpsampling<PointInT, PointOutT> >
ConstPtr
;
68
69
using
PCLBase
<PointInT>
::input_
;
70
using
PCLBase
<PointInT>
::indices_
;
71
using
PCLBase
<PointInT>
::initCompute
;
72
using
PCLBase
<PointInT>
::deinitCompute
;
73
using
CloudSurfaceProcessing
<PointInT, PointOutT>
::process
;
74
75
using
PointCloudOut
=
pcl::PointCloud<PointOutT>
;
76
77
Eigen::Matrix3f
KinectVGAProjectionMatrix
,
KinectSXGAProjectionMatrix
;
78
79
/** \brief Constructor. */
80
BilateralUpsampling
()
81
: window_size_ (5)
82
, sigma_color_ (15.0f)
83
, sigma_depth_ (0.5f)
84
{
85
KinectVGAProjectionMatrix
<< 525.0f, 0.0f, 320.0f,
86
0.0f, 525.0f, 240.0f,
87
0.0f, 0.0f, 1.0f;
88
KinectSXGAProjectionMatrix
<< 1050.0f, 0.0f, 640.0f,
89
0.0f, 1050.0f, 480.0f,
90
0.0f, 0.0f, 1.0f;
91
};
92
93
/** \brief Method that sets the window size for the filter
94
* \param[in] window_size the given window size
95
*/
96
inline
void
97
setWindowSize
(
int
window_size) { window_size_ = window_size; }
98
99
/** \brief Returns the filter window size */
100
inline
int
101
getWindowSize
()
const
{
return
(window_size_); }
102
103
/** \brief Method that sets the sigma color parameter
104
* \param[in] sigma_color the new value to be set
105
*/
106
inline
void
107
setSigmaColor
(
const
float
&sigma_color) { sigma_color_ = sigma_color; }
108
109
/** \brief Returns the current sigma color value */
110
inline
float
111
getSigmaColor
()
const
{
return
(sigma_color_); }
112
113
/** \brief Method that sets the sigma depth parameter
114
* \param[in] sigma_depth the new value to be set
115
*/
116
inline
void
117
setSigmaDepth
(
const
float
&sigma_depth) { sigma_depth_ = sigma_depth; }
118
119
/** \brief Returns the current sigma depth value */
120
inline
float
121
getSigmaDepth
()
const
{
return
(sigma_depth_); }
122
123
/** \brief Method that sets the projection matrix to be used when unprojecting the points in the depth image
124
* back to (x,y,z) positions.
125
* \note There are 2 matrices already set in the class, used for the 2 modes available for the Kinect. They
126
* are tuned to be the same as the ones in the OpenNiGrabber
127
* \param[in] projection_matrix the new projection matrix to be set */
128
inline
void
129
setProjectionMatrix
(
const
Eigen::Matrix3f &projection_matrix) { projection_matrix_ = projection_matrix; }
130
131
/** \brief Returns the current projection matrix */
132
inline
Eigen::Matrix3f
133
getProjectionMatrix
()
const
{
return
(projection_matrix_); }
134
135
/** \brief Method that does the actual processing on the input cloud.
136
* \param[out] output the container of the resulting upsampled cloud */
137
void
138
process
(
pcl::PointCloud<PointOutT>
&output)
override
;
139
140
protected
:
141
void
142
performProcessing
(
pcl::PointCloud<PointOutT>
&output)
override
;
143
144
/** \brief Computes the distance for depth and RGB.
145
* \param[out] val_exp_depth distance values for depth
146
* \param[out] val_exp_rgb distance values for RGB */
147
void
148
computeDistances
(Eigen::MatrixXf &val_exp_depth, Eigen::VectorXf &val_exp_rgb);
149
150
private
:
151
int
window_size_;
152
float
sigma_color_, sigma_depth_;
153
Eigen::Matrix3f projection_matrix_, unprojection_matrix_;
154
155
public
:
156
PCL_MAKE_ALIGNED_OPERATOR_NEW
157
};
158
}
pcl::BilateralUpsampling::getSigmaDepth
float getSigmaDepth() const
Returns the current sigma depth value.
Definition
bilateral_upsampling.h:121
pcl::BilateralUpsampling::KinectSXGAProjectionMatrix
Eigen::Matrix3f KinectSXGAProjectionMatrix
Definition
bilateral_upsampling.h:77
pcl::BilateralUpsampling::computeDistances
void computeDistances(Eigen::MatrixXf &val_exp_depth, Eigen::VectorXf &val_exp_rgb)
Computes the distance for depth and RGB.
Definition
bilateral_upsampling.hpp:156
pcl::BilateralUpsampling::setProjectionMatrix
void setProjectionMatrix(const Eigen::Matrix3f &projection_matrix)
Method that sets the projection matrix to be used when unprojecting the points in the depth image bac...
Definition
bilateral_upsampling.h:129
pcl::BilateralUpsampling::ConstPtr
shared_ptr< const BilateralUpsampling< PointInT, PointOutT > > ConstPtr
Definition
bilateral_upsampling.h:67
pcl::BilateralUpsampling::getProjectionMatrix
Eigen::Matrix3f getProjectionMatrix() const
Returns the current projection matrix.
Definition
bilateral_upsampling.h:133
pcl::BilateralUpsampling::BilateralUpsampling
BilateralUpsampling()
Constructor.
Definition
bilateral_upsampling.h:80
pcl::BilateralUpsampling::process
void process(pcl::PointCloud< PointOutT > &output) override
Method that does the actual processing on the input cloud.
Definition
bilateral_upsampling.hpp:50
pcl::BilateralUpsampling::getSigmaColor
float getSigmaColor() const
Returns the current sigma color value.
Definition
bilateral_upsampling.h:111
pcl::BilateralUpsampling::KinectVGAProjectionMatrix
Eigen::Matrix3f KinectVGAProjectionMatrix
Definition
bilateral_upsampling.h:77
pcl::BilateralUpsampling::PointCloudOut
pcl::PointCloud< PointOutT > PointCloudOut
Definition
bilateral_upsampling.h:75
pcl::BilateralUpsampling::performProcessing
void performProcessing(pcl::PointCloud< PointOutT > &output) override
Abstract cloud processing method.
Definition
bilateral_upsampling.hpp:88
pcl::BilateralUpsampling::Ptr
shared_ptr< BilateralUpsampling< PointInT, PointOutT > > Ptr
Definition
bilateral_upsampling.h:66
pcl::BilateralUpsampling::setSigmaDepth
void setSigmaDepth(const float &sigma_depth)
Method that sets the sigma depth parameter.
Definition
bilateral_upsampling.h:117
pcl::BilateralUpsampling::setWindowSize
void setWindowSize(int window_size)
Method that sets the window size for the filter.
Definition
bilateral_upsampling.h:97
pcl::BilateralUpsampling::setSigmaColor
void setSigmaColor(const float &sigma_color)
Method that sets the sigma color parameter.
Definition
bilateral_upsampling.h:107
pcl::BilateralUpsampling::getWindowSize
int getWindowSize() const
Returns the filter window size.
Definition
bilateral_upsampling.h:101
pcl::CloudSurfaceProcessing::CloudSurfaceProcessing
CloudSurfaceProcessing()
Constructor.
Definition
processing.h:70
pcl::PCLBase
PCL base class.
Definition
pcl_base.h:70
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
Definition
pcl_base.h:150
pcl::PCLBase< PointInT >::initCompute
bool initCompute()
pcl::PCLBase< PointInT >::deinitCompute
bool deinitCompute()
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition
point_cloud.h:173
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition
memory.h:63
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl
Definition
convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.