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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST