Point Cloud Library (PCL)  1.8.0
morphology.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, 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 the copyright holder(s) 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  */
37 
38 #ifndef PCL_2D_MORPHOLOGY_H_
39 #define PCL_2D_MORPHOLOGY_H_
40 
41 #include <pcl/pcl_base.h>
42 
43 namespace pcl
44 {
45  template <typename PointT>
46  class Morphology : public PCLBase<PointT>
47  {
48  private:
49  typedef typename pcl::PointCloud<PointT> PointCloudIn;
50  typedef typename PointCloudIn::Ptr PointCloudInPtr;
51 
52  PointCloudInPtr structuring_element_;
53 
54  public:
56 
57  Morphology () {}
58 
59  /** \brief This function performs erosion followed by dilation.
60  * It is useful for removing noise in the form of small blobs and patches.
61  * \param[out] output Output point cloud passed by reference
62  */
63  void
65 
66  /** \brief This function performs dilation followed by erosion.
67  * It is useful for filling up (holes/cracks/small discontinuities) in a binary
68  * segmented region
69  * \param[out] output Output point cloud passed by reference
70  */
71  void
73 
74  /** \brief Binary dilation is similar to a logical disjunction of sets.
75  * At each pixel having value 1, if for all pixels in the structuring element having value 1, the corresponding
76  * pixels in the input image are also 1, the center pixel is set to 1. Otherwise, it is set to 0.
77  * \param[out] output Output point cloud passed by reference
78  */
79  void
81 
82  /** \brief Binary erosion is similar to a logical addition of sets.
83  * At each pixel having value 1, if at least one pixel in the structuring element is 1 and the corresponding point
84  * in the input image is 1, the center pixel is set to 1. Otherwise, it is set to 0.
85  * \param[out] output Output point cloud passed by reference
86  */
87  void
89 
90  /** \brief Grayscale erosion followed by dilation.
91  * This is used to remove small bright artifacts from the image. Large bright objects are relatively undisturbed.
92  * \param[out] output Output point cloud passed by reference
93  */
94  void
96 
97  /** \brief Grayscale dilation followed by erosion.
98  * This is used to remove small dark artifacts from the image. Bright features or large dark features are relatively undisturbed.
99  * \param[out] output Output point cloud passed by reference
100  */
101  void
103 
104  /** \brief Takes the min of the pixels where kernel is 1
105  * \param[out] output Output point cloud passed by reference
106  */
107  void
109 
110  /** \brief Takes the max of the pixels where kernel is 1
111  * \param[out] output Output point cloud passed by reference
112  */
113  void
115 
116  /** \brief Set operation
117  * output = input1 - input2
118  * \param[out] output Output point cloud passed by reference
119  * \param[in] input1
120  * \param[in] input2
121  */
122  void
124  const pcl::PointCloud<PointT> &input1,
125  const pcl::PointCloud<PointT> &input2);
126 
127  /** \brief Set operation
128  * \f$output = input1 \cup input2\f$
129  * \param[out] output Output point cloud passed by reference
130  * \param[in] input1
131  * \param[in] input2
132  */
133  void
135  const pcl::PointCloud<PointT> &input1,
136  const pcl::PointCloud<PointT> &input2);
137 
138  /** \brief Set operation \f$ output = input1 \cap input2 \f$
139  * \param[out] output Output point cloud passed by reference
140  * \param[in] input1
141  * \param[in] input2
142  */
143  void
145  const pcl::PointCloud<PointT> &input1,
146  const pcl::PointCloud<PointT> &input2);
147 
148  /** \brief Creates a circular structing element. The size of the kernel created is 2*radius x 2*radius.
149  * Center of the structuring element is the center of the circle.
150  * All values lying on the circle are 1 and the others are 0.
151  *
152  * \param[out] kernel structuring element kernel passed by reference
153  * \param[in] radius Radius of the circular structuring element.
154  */
155  void
157 
158  /** \brief Creates a rectangular structing element of size height x width. *
159  * All values are 1.
160  *
161  * \param[out] kernel structuring element kernel passed by reference
162  * \param[in] height height number of rows in the structuring element
163  * \param[in] width number of columns in the structuring element
164  *
165  */
166  void
168  const int height, const int width);
169 
171  {
180  };
181 
183 
184  /**
185  * \param[out] output Output point cloud passed by reference
186  */
187  void
189 
190  /**
191  * \param[in] structuring_element The structuring element to be used for the morphological operation
192  */
193  void
194  setStructuringElement (const PointCloudInPtr &structuring_element);
195  };
196 }
197 
198 #include <pcl/2d/impl/morphology.hpp>
199 
200 #endif // PCL_2D_MORPHOLOGY_H_
void setStructuringElement(const PointCloudInPtr &structuring_element)
Definition: morphology.hpp:375
void dilationGray(pcl::PointCloud< PointT > &output)
Takes the max of the pixels where kernel is 1.
Definition: morphology.hpp:211
void openingGray(pcl::PointCloud< PointT > &output)
Grayscale erosion followed by dilation.
Definition: morphology.hpp:255
void subtractionBinary(pcl::PointCloud< PointT > &output, const pcl::PointCloud< PointT > &input1, const pcl::PointCloud< PointT > &input2)
Set operation output = input1 - input2.
Definition: morphology.hpp:275
void structuringElementCircular(pcl::PointCloud< PointT > &kernel, const int radius)
Creates a circular structing element.
Definition: morphology.hpp:341
void erosionBinary(pcl::PointCloud< PointT > &output)
Binary dilation is similar to a logical disjunction of sets.
Definition: morphology.hpp:44
void openingBinary(pcl::PointCloud< PointT > &output)
This function performs erosion followed by dilation.
Definition: morphology.hpp:147
void unionBinary(pcl::PointCloud< PointT > &output, const pcl::PointCloud< PointT > &input1, const pcl::PointCloud< PointT > &input2)
Set operation .
Definition: morphology.hpp:297
MORPHOLOGICAL_OPERATOR_TYPE operator_type
Definition: morphology.h:182
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
void closingBinary(pcl::PointCloud< PointT > &output)
This function performs dilation followed by erosion.
Definition: morphology.hpp:158
void erosionGray(pcl::PointCloud< PointT > &output)
Takes the min of the pixels where kernel is 1.
Definition: morphology.hpp:168
PCL base class.
Definition: pcl_base.h:68
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void dilationBinary(pcl::PointCloud< PointT > &output)
Binary erosion is similar to a logical addition of sets.
Definition: morphology.hpp:99
void applyMorphologicalOperation(pcl::PointCloud< PointT > &output)
void structuringElementRectangle(pcl::PointCloud< PointT > &kernel, const int height, const int width)
Creates a rectangular structing element of size height x width.
Definition: morphology.hpp:363
void closingGray(pcl::PointCloud< PointT > &output)
Grayscale dilation followed by erosion.
Definition: morphology.hpp:265
void intersectionBinary(pcl::PointCloud< PointT > &output, const pcl::PointCloud< PointT > &input1, const pcl::PointCloud< PointT > &input2)
Set operation .
Definition: morphology.hpp:319