normalisation¶
Pixel-to-normalized (and vice versa) coordinate transformations.
This module provides:
pix2norm: Convert pixel coordinates in an image to normalized coordinates.norm2pix: Convert normalized coordinates back into pixel coordinates.
pix2norm ¶
Convert image-space coordinates to normalized coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
|
A tuple (height, width) for the original image shape. |
required |
pts
|
|
A NumPy array of shape (..., 1, 2) holding (x, y) coordinates. |
required |
Returns:
| Type | Description |
|---|---|
|
A NumPy array of the same shape as |
|
roughly [-1, +1] range, scaled and offset based on |
Source code in src/page_dewarp/normalisation.py
norm2pix ¶
Convert normalized coordinates to image-space pixel coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
|
A tuple (height, width) for the target image shape. |
required |
pts
|
|
A NumPy array of shape (..., 1, 2) containing normalized (x, y) coordinates. |
required |
as_integer
|
|
If True, return integer pixel coordinates (rounded). Otherwise, return floating-point pixel coordinates. |
required |
Returns:
| Type | Description |
|---|---|
|
A NumPy array of the same shape as |
|
in the specified image dimensions. |