keypoints¶
Keypoint indexing and projection utilities.
This module provides helper functions to:
- Generate a "keypoint index" array from span counts (for referencing parameters).
- Project keypoints (in a parameter vector) into 2D coordinates using a cubic model.
make_keypoint_index ¶
Construct an index array to map spans to keypoint parameters.
Given a list of span_counts, where each value indicates how many keypoints
belong to that span, this function returns a 2D integer array of shape
(total_points + 1, 2). The indexing scheme is used elsewhere for referencing
keypoints in a parameter vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
span_counts
|
|
A list of integers, each giving the number of keypoints in a span. |
required |
Returns:
| Type | Description |
|---|---|
|
A 2D numpy array of shape (N+1, 2), where N is the sum of |
|
It encodes both a "point index" (in |
|
The first row is reserved or initialized to zero, and subsequent rows are |
|
populated to align with internal parameter-vector indexing conventions. |
Source code in src/page_dewarp/keypoints.py
project_keypoints ¶
Project parameter-vector keypoints into 2D coordinates.
Given a parameter vector pvec and an indexing array keypoint_index,
this function extracts the relevant keypoints, sets the first row to the origin,
and then applies a cubic projection via project_xy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pvec
|
|
A 2D parameter array or vector from which to extract keypoints. |
required |
keypoint_index
|
|
The index array mapping each keypoint row to a location in |
required |
Returns:
| Type | Description |
|---|---|
|
A numpy array of projected XY coordinates, as returned by |