MRPT  1.9.9
TRangeImageFilter.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/math/CMatrixF.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 */
28  bool rangeCheckBetween{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` */
36  const mrpt::math::CMatrixF *rangeMask_min{nullptr}, *rangeMask_max{nullptr};
37 
38  /** If enabled, the range pixels of points that do NOT pass the mask filter
39  * will be marked as invalid ranges (=0) in the source 3D observation
40  * object. */
41  bool mark_invalid_ranges{false};
42 
43  TRangeImageFilterParams() = default;
44 };
45 
46 /** Mainly for internal use within
47  * CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
49 {
51  /** Returns true if the point (r,c) with depth D passes all filters. */
52  inline bool do_range_filter(size_t r, size_t c, const float D) const;
53  inline TRangeImageFilter(const TRangeImageFilterParams& filter_params)
54  : fp(filter_params)
55  {
56  }
57  inline TRangeImageFilter() = default;
58 };
59 
60 // ======== Implementation ========
61 bool TRangeImageFilter::do_range_filter(size_t r, size_t c, const float D) const
62 {
63  // Filters:
64  if (D <= .0f) return false;
65  // Greater-than/Less-than filters:
66  bool pass_gt = true, pass_lt = true;
67  bool has_min_filter = false, has_max_filter = false;
68  if (fp.rangeMask_min)
69  {
70  const float min_d = fp.rangeMask_min->coeff(r, c);
71  if (min_d != .0f)
72  {
73  has_min_filter = true;
74  pass_gt = (D >= min_d);
75  }
76  }
77  if (fp.rangeMask_max)
78  {
79  const float max_d = fp.rangeMask_max->coeff(r, c);
80  if (max_d != .0f)
81  {
82  has_max_filter = true;
83  pass_lt = (D <= max_d);
84  }
85  }
86  if (has_min_filter && has_max_filter)
87  {
88  return fp.rangeCheckBetween ? (pass_gt && pass_lt)
89  : !(pass_gt && pass_lt);
90  }
91  else
92  return pass_gt && pass_lt;
93 }
94 } // namespace mrpt::obs
Mainly for internal use within CObservation3DRangeScan::project3DPointsFromDepthImageInto() ...
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
const mrpt::math::CMatrixF * rangeMask_max
const GLubyte * c
Definition: glext.h:6406
This namespace contains representation of robot actions and observations.
TRangeImageFilter(const TRangeImageFilterParams &filter_params)
TRangeImageFilterParams fp
const mrpt::math::CMatrixF * rangeMask_min
(Default: nullptr) If provided, each data range will be tested to be greater-than (rangeMask_min) or ...
bool mark_invalid_ranges
If enabled, the range pixels of points that do NOT pass the mask filter will be marked as invalid ran...
const Scalar & coeff(int r, int c) const
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrixF.h:22
GLdouble GLdouble GLdouble r
Definition: glext.h:3711
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: 9b18308f3 Mon Nov 18 23:39:25 2019 +0100 at lun nov 18 23:45:12 CET 2019