cuvis_ai.transformation.reflectance.Reflectance

class cuvis_ai.transformation.reflectance.Reflectance(lower_bound: float = 0.0, upper_bound: float = 2.0)[source]

Bases: Node, BaseTransformation

Generic reflectance calculus: (data - dark) / (white - dark) Requires “Dark” and “White” references to be set in Metadata.

Parameters:
  • lower_bound (float, optional) – Threshold for the smallest allowed value, everything lower will be clamped. Set to None to allow any value. Default: 0.0

  • upper_bound (float, optional) – Threshold for the largest allowed value, everything higher will be clamped. Set to None to allow any value. Default: 2.0

__init__(lower_bound: float = 0.0, upper_bound: float = 2.0)[source]

Methods

__init__([lower_bound, upper_bound])

check_input_dim(X)

Check that the parameters for the input data data match user expectations

check_output_dim(X)

Check that the parameters for the output data data match user expectations

forward(X, references__White, references__Dark)

Apply reflectance calculus to the data.

get_fit_requested_meta()

get_forward_requested_meta()

load(params, serial_dir)

Load this node from a serialized graph.

serialize(serial_dir)

Serialize this node.

set_fit_meta_request(**kwargs)

set_forward_meta_request(**kwargs)

Attributes

input_dim

Returns the needed shape for the input data.

output_dim

Returns the shape for the output data.

check_input_dim(X)

Check that the parameters for the input data data match user expectations

Parameters: X (array-like): Input data.

Returns: (Bool) Valid data

check_output_dim(X)

Check that the parameters for the output data data match user expectations

Parameters: X (array-like): Input data.

Returns: (Bool) Valid data

forward(X: ndarray, references__White: ndarray, references__Dark: ndarray)[source]

Apply reflectance calculus to the data. Returns the data as percentage values between the “Dark” and “White” references set in the meta-data. e.g. A pixel value of 1.0 means that the pixel is as bright as the white reference at this pixel, 1.5 -> 50% brighter, 0.0 -> as bright as the dark reference, -0.2 -> 20% darker than the dark reference. The output values can be clamped by setting lower_bond and upper_bound.

Parameters
Xnp.ndarray

The input data array for which reflectance is computed. Must have the same shape as references__White and references__Dark.

references__Whitenp.ndarray

The white reference array. Defines the maximum intensity for each pixel.

references__Darknp.ndarray

The dark reference array. Defines the minimum intensity for each pixel.

np.ndarray

An array of reflectance values with the same shape as the input X. The reflectance values are computed as (X - references__Dark) / (references__White - references__Dark) and optionally clamped between the lower and upper bounds.

get_fit_requested_meta()
get_forward_requested_meta()
property input_dim: tuple[int, int, int]

Returns the needed shape for the input data. If a dimension is not important, it will return -1 in the specific position.

Returns: (tuple) needed shape for data

load(params: dict, serial_dir: str) None[source]

Load this node from a serialized graph.

property output_dim: tuple[int, int, int]

Returns the shape for the output data. If a dimension is dependent on the input, it will return -1 in the specific position.

Returns: (tuple) expected output shape for data

serialize(serial_dir: str) dict[source]

Serialize this node.

set_fit_meta_request(**kwargs)
set_forward_meta_request(**kwargs)