lagrange.image

Classes

ImageChannel

Image channel

ImagePrecision

Image pixel precision

ImageStorage

Image storage class

Functions

split_grid(grid, num_cells[, rows, cols])

Split a grid image into num_cells row-major sub-images.

Module Contents

class lagrange.image.ImageChannel

Bases: enum.Enum

Image channel

four = 4
one = 1
three = 3
unknown = 5
class lagrange.image.ImagePrecision

Bases: enum.Enum

Image pixel precision

float16 = 7
float32 = 5
float64 = 6
int32 = 4
int8 = 1
uint32 = 3
uint8 = 0
unknown = 8
class lagrange.image.ImageStorage(width, height, alignment)

Image storage class

Parameters:
  • width (int)

  • height (int)

  • alignment (int)

property data: Annotated[numpy.typing.NDArray[numpy.uint8], dict(order='C', device='cpu')]

Raw image data

Return type:

Annotated[numpy.typing.NDArray[numpy.uint8], dict(order=’C’, device=’cpu’)]

property height: int

Image height

Return type:

int

property stride: int

Image stride

Return type:

int

property width: int

Image width

Return type:

int

lagrange.image.split_grid(grid, num_cells, rows=0, cols=0)

Split a grid image into num_cells row-major sub-images.

The grid is split into rows x cols cells. A value of zero on either dimension means auto-detect:

  • rows=0, cols=0: pick the factorization producing cells closest to square.

  • rows=R, cols=0: derive cols = num_cells / R.

  • rows=0, cols=C: derive rows = num_cells / C.

  • rows=R, cols=C: validate R * C == num_cells.

Returned views share memory with the input grid (no copy).

Parameters:
  • grid (Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]) – HxWxC grid image as a numpy array.

  • num_cells (int) – Number of cells to split the grid into.

  • rows (int) – Number of cell rows in the grid (0 = auto).

  • cols (int) – Number of cell columns in the grid (0 = auto).

Returns:

List of num_cells numpy views into the grid, in row-major order.

Return type:

list[object]