display_transforms
anomaly_match_ui.utils.display_transforms
¶
Display transform functions for image visualization.
prepare_for_display(img, rgb_mapping=None)
¶
Prepare N-channel image for RGB display.
Converts images with arbitrary channel counts to 3-channel RGB for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
ndarray
|
Input image array with shape (H, W, C). |
required |
rgb_mapping
|
list[int] | None
|
List of 3 channel indices to use as RGB. Defaults to [0, 1, 2] (first 3 channels). |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: 3-channel RGB image with shape (H, W, 3) and dtype uint8. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input is not a numpy array or PIL Image, or if
|
Source code in anomaly_match_ui/utils/display_transforms.py
display_image_normalisation(img, rgb_mapping=None)
¶
Normalises the image for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
ndarray
|
The input image array. |
required |
rgb_mapping
|
list[int] | None
|
For N-channel images, which channels to display as RGB. |
None
|
Returns:
| Type | Description |
|---|---|
Image
|
PIL.Image.Image: The normalised image. |
Source code in anomaly_match_ui/utils/display_transforms.py
apply_transforms_ui(img, invert, brightness, contrast, unsharp_mask_applied, show_r=True, show_g=True, show_b=True)
¶
Applies the requested transformations to the given PIL Image.
The image is always 3-channel RGB by the time it reaches here
(:func:display_image_normalisation collapses any band count to RGB), so
channel toggling is expressed purely as the three show_* flags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
The original image. |
required |
invert
|
bool
|
Whether to invert colors. |
required |
brightness
|
float
|
Brightness factor. |
required |
contrast
|
float
|
Contrast factor. |
required |
unsharp_mask_applied
|
bool
|
Whether to apply an unsharp mask. |
required |
show_r
|
bool
|
Whether to show the red channel. |
True
|
show_g
|
bool
|
Whether to show the green channel. |
True
|
show_b
|
bool
|
Whether to show the blue channel. |
True
|
Returns:
| Type | Description |
|---|---|
Image
|
PIL.Image.Image: The transformed image. |