Main MRPT website > C++ reference for MRPT 1.9.9
TRangeImageFilter.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef TRangeImageFilter_H
10 #define CObservation3DRangeScan_H
11 
12 #include <mrpt/utils/core_defs.h>
13 #include <mrpt/math/CMatrix.h>
14 
15 namespace mrpt
16 {
17 namespace obs
18 {
19 /** Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
21 {
22  /** Only used if <b>both</b> rangeMask_min and rangeMask_max are present.
23  * This switches which condition must fulfill a range `D` to be accepted as
24  * valid:
25  * - `rangeCheckBetween=true` : valid = (D>=rangeMask_min &&
26  * D<=rangeMask_max)
27  * - `rangeCheckBetween=false`: valid = !(D>=rangeMask_min &&
28  * D<=rangeMask_max)
29  *
30  * \note Default value:true */
32  /** (Default: nullptr) If provided, each data range will be tested to be
33  * greater-than (rangeMask_min) or less-than (rangeMask_max) each element in
34  * these matrices
35  * for each direction (row,col). Values of 0.0f mean no filtering at those
36  * directions.
37  * If both `rangeMask_min` and `rangeMask_max` are provided, the joint
38  * filtering operation is determined by `rangeCheckBetween` */
41  : rangeCheckBetween(true),
42  rangeMask_min(nullptr),
43  rangeMask_max(nullptr)
44  {
45  }
46 };
47 
48 /** Mainly for internal use within
49  * CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
51 {
53  /** Returns true if the point (r,c) with depth D passes all filters. */
54  inline bool do_range_filter(size_t r, size_t c, const float D) const;
55  inline TRangeImageFilter(const TRangeImageFilterParams& filter_params)
56  : fp(filter_params)
57  {
58  }
59  inline TRangeImageFilter() {}
60 };
61 
62 // ======== Implementation ========
63 bool TRangeImageFilter::do_range_filter(size_t r, size_t c, const float D) const
64 {
65  // Filters:
66  if (D <= .0f) return false;
67  // Greater-than/Less-than filters:
68  bool pass_gt = true, pass_lt = true;
69  bool has_min_filter = false, has_max_filter = false;
70  if (fp.rangeMask_min)
71  {
72  const float min_d = fp.rangeMask_min->coeff(r, c);
73  if (min_d != .0f)
74  {
75  has_min_filter = true;
76  pass_gt = (D >= min_d);
77  }
78  }
79  if (fp.rangeMask_max)
80  {
81  const float max_d = fp.rangeMask_max->coeff(r, c);
82  if (max_d != .0f)
83  {
84  has_max_filter = true;
85  pass_lt = (D <= max_d);
86  }
87  }
88  if (has_min_filter && has_max_filter)
89  {
90  return fp.rangeCheckBetween ? (pass_gt && pass_lt)
91  : !(pass_gt && pass_lt);
92  }
93  else
94  return pass_gt && pass_lt;
95 } // do_range_filter()
96 }
97 } // End of namespaces
98 
99 #endif
Mainly for internal use within CObservation3DRangeScan::project3DPointsFromDepthImageInto() ...
const mrpt::math::CMatrix * rangeMask_min
(Default: nullptr) If provided, each data range will be tested to be greater-than (rangeMask_min) or ...
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
const GLubyte * c
Definition: glext.h:6313
TRangeImageFilter(const TRangeImageFilterParams &filter_params)
TRangeImageFilterParams fp
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
const mrpt::math::CMatrix * rangeMask_max
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:25
bool do_range_filter(size_t r, size_t c, const float D) const
Returns true if the point (r,c) with depth D passes all filters.
bool rangeCheckBetween
Only used if both rangeMask_min and rangeMask_max are present.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019