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-2018, 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/math/CMatrix.h>
13 
14 namespace mrpt::obs
15 {
16 /** Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
18 {
19  /** Only used if <b>both</b> rangeMask_min and rangeMask_max are present.
20  * This switches which condition must fulfill a range `D` to be accepted as
21  * valid:
22  * - `rangeCheckBetween=true` : valid = (D>=rangeMask_min &&
23  * D<=rangeMask_max)
24  * - `rangeCheckBetween=false`: valid = !(D>=rangeMask_min &&
25  * D<=rangeMask_max)
26  *
27  * \note Default value:true */
29  /** (Default: nullptr) If provided, each data range will be tested to be
30  * greater-than (rangeMask_min) or less-than (rangeMask_max) each element in
31  * these matrices
32  * for each direction (row,col). Values of 0.0f mean no filtering at those
33  * directions.
34  * If both `rangeMask_min` and `rangeMask_max` are provided, the joint
35  * filtering operation is determined by `rangeCheckBetween` */
38  : rangeCheckBetween(true),
39  rangeMask_min(nullptr),
40  rangeMask_max(nullptr)
41  {
42  }
43 };
44 
45 /** Mainly for internal use within
46  * CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
48 {
50  /** Returns true if the point (r,c) with depth D passes all filters. */
51  inline bool do_range_filter(size_t r, size_t c, const float D) const;
52  inline TRangeImageFilter(const TRangeImageFilterParams& filter_params)
53  : fp(filter_params)
54  {
55  }
56  inline TRangeImageFilter() {}
57 };
58 
59 // ======== Implementation ========
60 bool TRangeImageFilter::do_range_filter(size_t r, size_t c, const float D) const
61 {
62  // Filters:
63  if (D <= .0f) return false;
64  // Greater-than/Less-than filters:
65  bool pass_gt = true, pass_lt = true;
66  bool has_min_filter = false, has_max_filter = false;
67  if (fp.rangeMask_min)
68  {
69  const float min_d = fp.rangeMask_min->coeff(r, c);
70  if (min_d != .0f)
71  {
72  has_min_filter = true;
73  pass_gt = (D >= min_d);
74  }
75  }
76  if (fp.rangeMask_max)
77  {
78  const float max_d = fp.rangeMask_max->coeff(r, c);
79  if (max_d != .0f)
80  {
81  has_max_filter = true;
82  pass_lt = (D <= max_d);
83  }
84  }
85  if (has_min_filter && has_max_filter)
86  {
87  return fp.rangeCheckBetween ? (pass_gt && pass_lt)
88  : !(pass_gt && pass_lt);
89  }
90  else
91  return pass_gt && pass_lt;
92 }
93 } // End of namespaces
94 
95 #endif
96 
97 
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
This namespace contains representation of robot actions and observations.
TRangeImageFilter(const TRangeImageFilterParams &filter_params)
TRangeImageFilterParams fp
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:22
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020