smarts.sstudio.graphics.heightfield module

class smarts.sstudio.graphics.heightfield.HeightField(data: ndarray, size: Tuple[int, int] | ndarray, metadata: Dict | None = None)[source]

A utility for working with greyscale values.

add(other: HeightField) HeightField[source]

Add by element.

apply_function(fn: Callable[[ndarray, int, int], uint8], min_val=-inf, max_val=inf)[source]

Apply a function to each element.

apply_kernel(kernel: ndarray, min_val=-inf, max_val=inf, pad_mode='edge')[source]

Apply a kernel to the whole height field.

The kernel can be asymmetric but still needs each dimension to be an odd value.

property data

The raw underlying data.

property dtype

The per element data type.

classmethod from_rgb(data: ndarray)[source]

Load from an rgb array.

inverted() HeightField[source]

Invert this height field assuming 8 bit.

classmethod load_image(file: str | Path)[source]

Load from any image.

max(other: HeightField) HeightField[source]

Get the maximum value of overlapping height fields.

property metadata

Additional metadata.

multiply(other: HeightField) HeightField[source]

Multiply the byte values between these height fields

property resolution

Resolution of this height field.

scale_by(other: HeightField) HeightField[source]

Scale this height field by another height field.

property size

The width and height.

subtract(other: HeightField) HeightField[source]

Subtract by element.

write_image(file: str | Path | BinaryIO)[source]

Write this out to a greyscale image.