Point Cloud Library (PCL) 1.12.1
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#pragma once
39
40#include <pcl/pcl_base.h>
41
42namespace pcl {
43
44template <typename PointT>
45class Morphology : public PCLBase<PointT> {
46private:
48 using PointCloudInPtr = typename PointCloudIn::Ptr;
49
50 PointCloudInPtr structuring_element_;
51
52public:
54
56
57 /** \brief This function performs erosion followed by dilation.
58 * It is useful for removing noise in the form of small blobs and patches.
59 * \param[out] output Output point cloud passed by reference
60 */
61 void
63
64 /** \brief This function performs dilation followed by erosion.
65 * It is useful for filling up (holes/cracks/small discontinuities) in a binary
66 * segmented region
67 * \param[out] output Output point cloud passed by reference
68 */
69 void
71
72 /** \brief Binary dilation is similar to a logical disjunction of sets.
73 * At each pixel having value 1, if for all pixels in the structuring element having
74 * value 1, the corresponding pixels in the input image are also 1, the center pixel
75 * is set to 1. Otherwise, it is set to 0.
76 *
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
84 * 1 and the corresponding point in the input image is 1, the center pixel is set
85 * to 1. Otherwise, it is set to 0.
86 *
87 * \param[out] output Output point cloud passed by reference
88 */
89 void
91
92 /** \brief Grayscale erosion followed by dilation.
93 * This is used to remove small bright artifacts from the image. Large bright objects
94 * are relatively undisturbed.
95 *
96 * \param[out] output Output point cloud passed by reference
97 */
98 void
100
101 /** \brief Grayscale dilation followed by erosion.
102 * This is used to remove small dark artifacts from the image. Bright features or
103 * large dark features are relatively undisturbed.
104 *
105 * \param[out] output Output point cloud passed by reference
106 */
107 void
109
110 /** \brief Takes the min of the pixels where kernel is 1
111 * \param[out] output Output point cloud passed by reference
112 */
113 void
115
116 /** \brief Takes the max of the pixels where kernel is 1
117 * \param[out] output Output point cloud passed by reference
118 */
119 void
121
122 /** \brief Set operation
123 * output = input1 - input2
124 * \param[out] output Output point cloud passed by reference
125 * \param[in] input1
126 * \param[in] input2
127 */
128 void
130 const pcl::PointCloud<PointT>& input1,
131 const pcl::PointCloud<PointT>& input2);
132
133 /** \brief Set operation
134 * \f$output = input1 \cup input2\f$
135 * \param[out] output Output point cloud passed by reference
136 * \param[in] input1
137 * \param[in] input2
138 */
139 void
141 const pcl::PointCloud<PointT>& input1,
142 const pcl::PointCloud<PointT>& input2);
143
144 /** \brief Set operation \f$ output = input1 \cap input2 \f$
145 * \param[out] output Output point cloud passed by reference
146 * \param[in] input1
147 * \param[in] input2
148 */
149 void
151 const pcl::PointCloud<PointT>& input1,
152 const pcl::PointCloud<PointT>& input2);
153
154 /** \brief Creates a circular structing element. The size of the kernel created is
155 * 2*radius x 2*radius. Center of the structuring element is the center of the circle.
156 * All values lying on the circle are 1 and the others are 0.
157 *
158 * \param[out] kernel structuring element kernel passed by reference
159 * \param[in] radius Radius of the circular structuring element.
160 */
161 void
163
164 /** \brief Creates a rectangular structing element of size height x width. *
165 * All values are 1.
166 *
167 * \param[out] kernel structuring element kernel passed by reference
168 * \param[in] height height number of rows in the structuring element
169 * \param[in] width number of columns in the structuring element
170 *
171 */
172 void
174 const int height,
175 const int width);
176
186 };
187
189
190 /**
191 * \param[out] output Output point cloud passed by reference
192 */
193 void
195
196 /**
197 * \param[in] structuring_element The structuring element to be used for the
198 * morphological operation
199 */
200 void
201 setStructuringElement(const PointCloudInPtr& structuring_element);
202};
203
204} // namespace pcl
205
206#include <pcl/2d/impl/morphology.hpp>
void dilationBinary(pcl::PointCloud< PointT > &output)
Binary erosion is similar to a logical addition of sets.
Definition: morphology.hpp:98
void subtractionBinary(pcl::PointCloud< PointT > &output, const pcl::PointCloud< PointT > &input1, const pcl::PointCloud< PointT > &input2)
Set operation output = input1 - input2.
Definition: morphology.hpp:269
void erosionGray(pcl::PointCloud< PointT > &output)
Takes the min of the pixels where kernel is 1.
Definition: morphology.hpp:164
void openingBinary(pcl::PointCloud< PointT > &output)
This function performs erosion followed by dilation.
Definition: morphology.hpp:143
void erosionBinary(pcl::PointCloud< PointT > &output)
Binary dilation is similar to a logical disjunction of sets.
Definition: morphology.hpp:47
void setStructuringElement(const PointCloudInPtr &structuring_element)
Definition: morphology.hpp:362
void closingGray(pcl::PointCloud< PointT > &output)
Grayscale dilation followed by erosion.
Definition: morphology.hpp:259
void closingBinary(pcl::PointCloud< PointT > &output)
This function performs dilation followed by erosion.
Definition: morphology.hpp:154
void intersectionBinary(pcl::PointCloud< PointT > &output, const pcl::PointCloud< PointT > &input1, const pcl::PointCloud< PointT > &input2)
Set operation .
Definition: morphology.hpp:309
void unionBinary(pcl::PointCloud< PointT > &output, const pcl::PointCloud< PointT > &input1, const pcl::PointCloud< PointT > &input2)
Set operation .
Definition: morphology.hpp:289
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:349
void applyMorphologicalOperation(pcl::PointCloud< PointT > &output)
void openingGray(pcl::PointCloud< PointT > &output)
Grayscale erosion followed by dilation.
Definition: morphology.hpp:249
void structuringElementCircular(pcl::PointCloud< PointT > &kernel, const int radius)
Creates a circular structing element.
Definition: morphology.hpp:329
MORPHOLOGICAL_OPERATOR_TYPE operator_type
Definition: morphology.h:188
void dilationGray(pcl::PointCloud< PointT > &output)
Takes the max of the pixels where kernel is 1.
Definition: morphology.hpp:206
PCL base class.
Definition: pcl_base.h:70
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413