Main MRPT website > C++ reference for MRPT 1.5.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 #include <mrpt/obs/link_pragmas.h>
15 
16 namespace mrpt {
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 valid:
24  * - `rangeCheckBetween=true` : valid = (D>=rangeMask_min && D<=rangeMask_max)
25  * - `rangeCheckBetween=false`: valid = !(D>=rangeMask_min && D<=rangeMask_max)
26  *
27  * \note Default value:true */
29  /** (Default: NULL) If provided, each data range will be tested to be greater-than (rangeMask_min) or less-than (rangeMask_max) each element in these matrices
30  * for each direction (row,col). Values of 0.0f mean no filtering at those directions.
31  * If both `rangeMask_min` and `rangeMask_max` are provided, the joint filtering operation is determined by `rangeCheckBetween` */
32  const mrpt::math::CMatrix * rangeMask_min, * rangeMask_max;
33 
34  /** If enabled, the range pixels of points that do NOT pass the mask filter
35  * will be marked as invalid ranges (=0) in the source 3D observation
36  * object. */
38 
39  TRangeImageFilterParams() : rangeCheckBetween(true), rangeMask_min(NULL), rangeMask_max(NULL), mark_invalid_ranges(false)
40  {}
41  };
42 
43  /** Mainly for internal use within CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
45  {
47  inline 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.
48  inline TRangeImageFilter(const TRangeImageFilterParams &filter_params) : fp(filter_params) {}
49  inline TRangeImageFilter() {}
50  };
51 
52 
53  // ======== Implementation ========
54  bool TRangeImageFilter::do_range_filter(size_t r, size_t c, const float D) const {
55  // Filters:
56  if (D<=.0f)
57  return false;
58  // Greater-than/Less-than filters:
59  bool pass_gt=true, pass_lt=true;
60  bool has_min_filter = false, has_max_filter = false;
61  if (fp.rangeMask_min) {
62  const float min_d = fp.rangeMask_min->coeff(r,c);
63  if (min_d!=.0f) {
64  has_min_filter = true;
65  pass_gt = (D>=min_d);
66  }
67  }
68  if (fp.rangeMask_max) {
69  const float max_d = fp.rangeMask_max->coeff(r,c);
70  if (max_d!=.0f) {
71  has_max_filter=true;
72  pass_lt = (D<=max_d);
73  }
74  }
75  if (has_min_filter && has_max_filter) {
76  return fp.rangeCheckBetween ? (pass_gt && pass_lt) : !(pass_gt && pass_lt);
77  }
78  else return pass_gt && pass_lt;
79  } // do_range_filter()
80 
81 } } // End of namespaces
82 
83 #endif
Mainly for internal use within CObservation3DRangeScan::project3DPointsFromDepthImageInto() ...
const mrpt::math::CMatrix * rangeMask_min
(Default: NULL) If provided, each data range will be tested to be greater-than (rangeMask_min) or les...
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
const GLubyte * c
Definition: glext.h:5590
TRangeImageFilter(const TRangeImageFilterParams &filter_params)
TRangeImageFilterParams fp
bool mark_invalid_ranges
If enabled, the range pixels of points that do NOT pass the mask filter will be marked as invalid ran...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3618
const mrpt::math::CMatrix * rangeMask_max
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:30
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.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020