MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ pyramid_layout()

PyramidLayout MayaFlux::Kinesis::Vision::pyramid_layout ( uint32_t  w,
uint32_t  h,
uint32_t  requested,
uint32_t  min_extent = 16 
)
inline

Place up to requested pyramid levels for a w x h base image.

Levels stop early when the next one would have a side under min_extent, so small images get fewer levels rather than degenerate ones. requested is clamped to [1, PyramidLayout::k_max_levels].

Parameters
wBase width in pixels.
hBase height in pixels.
requestedDesired number of levels including the base.
min_extentSmallest side a level may have.
Returns
Layout with level 0 at the origin and the rest stacked to its right.

Definition at line 63 of file Pyramid.hpp.

65{
66 PyramidLayout layout;
67 layout.level[0] = { .ox = 0, .oy = 0, .w = w, .h = h };
68
69 const uint32_t wanted = std::clamp(requested, 1U, PyramidLayout::k_max_levels);
70 uint32_t count = 1;
71 uint32_t column_h = 0;
72 uint32_t column_w = 0;
73
74 while (count < wanted) {
75 const auto& above = layout.level[count - 1];
76 const uint32_t lw = (above.w + 1U) / 2U;
77 const uint32_t lh = (above.h + 1U) / 2U;
78 if (std::min(lw, lh) < min_extent)
79 break;
80
81 layout.level[count] = { .ox = w, .oy = column_h, .w = lw, .h = lh };
82 column_h += lh;
83 column_w = std::max(column_w, lw);
84 ++count;
85 }
86
87 layout.levels = count;
88 layout.atlas_w = w + column_w;
89 layout.atlas_h = std::max(h, column_h);
90 return layout;
91}
uint32_t h
Definition InkPress.cpp:29
size_t count
std::array< PyramidLevel, k_max_levels > level
Definition Pyramid.hpp:34
Placement of every pyramid level in a single atlas.
Definition Pyramid.hpp:31

References MayaFlux::Kinesis::Vision::PyramidLayout::atlas_h, MayaFlux::Kinesis::Vision::PyramidLayout::atlas_w, count, h, MayaFlux::Kinesis::Vision::PyramidLayout::k_max_levels, MayaFlux::Kinesis::Vision::PyramidLayout::level, and MayaFlux::Kinesis::Vision::PyramidLayout::levels.

Referenced by MayaFlux::Yantra::VisionGpuExecutor::build_flow_pyramid().

+ Here is the caller graph for this function: