ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
visibility_pyramid.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <vector>
12 
13 #include "util/alignment.h"
14 
15 namespace colmap {
16 
17 // A class that captures the distribution of points in a 2D grid.
18 // For example, to capture the distribution of visible 3D points in an image.
19 //
20 // The class captures the distribution of points by a score. A higher score
21 // corresponds to a more uniform distribution of the points in the grid.
22 //
23 // The score is computed by the number of populated cells in a multi-resolution
24 // pyramid. A populated cell contributes to the overall score if it is
25 // populated by at least one point and the contributed score is according
26 // to its resolution in the pyramid. A cell in a higher resolution level
27 // contributes a higher score to the overall score.
29 public:
31  VisibilityPyramid(const size_t num_levels,
32  const size_t width,
33  const size_t height);
34 
35  void SetPoint(const double x, const double y);
36  void ResetPoint(const double x, const double y);
37 
38  inline size_t NumLevels() const;
39  inline size_t Width() const;
40  inline size_t Height() const;
41 
42  inline size_t Score() const;
43  inline size_t MaxScore() const;
44 
45 private:
46  void CellForPoint(const double x,
47  const double y,
48  size_t* cx,
49  size_t* cy) const;
50 
51  // Range of the input points.
52  size_t width_;
53  size_t height_;
54 
55  // The overall visibility score.
56  size_t score_;
57 
58  // The maximum score when all cells are populated.
59  size_t max_score_;
60 
61  // The visibilty pyramid with multiple levels.
62  std::vector<Eigen::MatrixXi> pyramid_;
63 };
64 
66 // Implementation
68 
69 size_t VisibilityPyramid::NumLevels() const { return pyramid_.size(); }
70 
71 size_t VisibilityPyramid::Width() const { return width_; }
72 
73 size_t VisibilityPyramid::Height() const { return height_; }
74 
75 size_t VisibilityPyramid::Score() const { return score_; }
76 
77 size_t VisibilityPyramid::MaxScore() const { return max_score_; }
78 
79 } // namespace colmap
int width
int height
void ResetPoint(const double x, const double y)
void SetPoint(const double x, const double y)
normal_z y
normal_z x