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  TRangeImageFilterParams() = default;
38 };
39 
40 /** Mainly for internal use within
41  * CObservation3DRangeScan::project3DPointsFromDepthImageInto() */
43 {
45  /** Returns true if the point (r,c) with depth D passes all filters. */
46  inline bool do_range_filter(size_t r, size_t c, const float D) const;
47  inline TRangeImageFilter(const TRangeImageFilterParams& filter_params)
48  : fp(filter_params)
49  {
50  }
51  inline TRangeImageFilter() = default;
52 };
53 
54 // ======== Implementation ========
55 bool TRangeImageFilter::do_range_filter(size_t r, size_t c, const float D) const
56 {
57  // Filters:
58  if (D <= .0f) return false;
59  // Greater-than/Less-than filters:
60  bool pass_gt = true, pass_lt = true;
61  bool has_min_filter = false, has_max_filter = false;
62  if (fp.rangeMask_min)
63  {
64  const float min_d = fp.rangeMask_min->coeff(r, c);
65  if (min_d != .0f)
66  {
67  has_min_filter = true;
68  pass_gt = (D >= min_d);
69  }
70  }
71  if (fp.rangeMask_max)
72  {
73  const float max_d = fp.rangeMask_max->coeff(r, c);
74  if (max_d != .0f)
75  {
76  has_max_filter = true;
77  pass_lt = (D <= max_d);
78  }
79  }
80  if (has_min_filter && has_max_filter)
81  {
82  return fp.rangeCheckBetween ? (pass_gt && pass_lt)
83  : !(pass_gt && pass_lt);
84  }
85  else
86  return pass_gt && pass_lt;
87 }
88 } // 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 ...
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: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019