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

◆ normalised_points_tight_region()

MAYAFLUX_API Region MayaFlux::Kakshya::normalised_points_tight_region ( std::span< const glm::vec2 >  points,
uint32_t  pixel_w,
uint32_t  pixel_h 
)

Compute the tight pixel-space Region enclosing a set of normalised points.

Iterates points to find the axis-aligned bounding box in normalised image space, then delegates to normalised_rect_to_region. Coordinate convention is identical: origin top-left, +Y downward, output inclusive pixel integers as { y0, x0 } / { y1, x1 }.

Returns a zero-area Region at { 0, 0 } / { 0, 0 } if points is empty.

Parameters
pointsNormalised image-space points in [0, 1] x [0, 1].
pixel_wSource image width in pixels.
pixel_hSource image height in pixels.
Returns
Tight bounding Region in pixel integers.

Definition at line 392 of file CoordUtils.cpp.

395{
396 if (points.empty())
397 return Region {};
398
399 float min_x = points[0].x, max_x = points[0].x;
400 float min_y = points[0].y, max_y = points[0].y;
401
402 for (const auto& p : points.subspan(1)) {
403 if (p.x < min_x)
404 min_x = p.x;
405 if (p.x > max_x)
406 max_x = p.x;
407 if (p.y < min_y)
408 min_y = p.y;
409 if (p.y > max_y)
410 max_y = p.y;
411 }
412
413 return normalised_rect_to_region(
414 min_x, min_y,
415 max_x - min_x, max_y - min_y,
416 pixel_w, pixel_h);
417}
std::vector< glm::vec2 > * points
Represents a point or span in N-dimensional space.
Definition Region.hpp:73

References normalised_rect_to_region(), and points.

+ Here is the call graph for this function: