utils/image_patch
module¶
image_patch
¶
Functions¶
create_patch_tiled_image
¶
create_patch_tiled_image(ls_patches: list[tuple[int, int, int]], patch_size: tuple[int, int, int] = (50, 50, 1)) -> np.ndarray
Generate a color patch image from a list of BGR values.
This function creates a color patch image by tiling BGR values into patches and arranging them in a 4x6 grid pattern. Each patch is repeated according to the specified patch size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ls_patches
|
list[tuple[int, int, int]]
|
List containing 24 BGR color tuples, where each tuple has three integers representing (B, G, R) values. |
required |
patch_size
|
tuple[int, int, int]
|
Size of each individual patch in pixels, by default (50, 50, 1). Format is (height, width, channels). |
(50, 50, 1)
|
Returns:
Type | Description |
---|---|
numpy.ndarray
|
Generated image as a numpy array with shape determined by patch_size and arrangement (4 rows x 6 columns). Array type is uint8. |
Notes
This function is specifically designed to work with 24 color patches arranged in a 4x6 grid pattern.
Examples:
>>> patches = [(255, 0, 0), (0, 255, 0), ...] # 24 BGR tuples
>>> patch_size = (50, 50, 1)
>>> image = generate_image_patches(patches, patch_size)
Source code in color_correction/utils/image_patch.py
visualize_patch_comparison
¶
visualize_patch_comparison(ls_mean_ref: np.ndarray, ls_mean_in: np.ndarray, patch_size: tuple[int, int, int] = (100, 100, 1)) -> np.ndarray
Compare two sets of image patches by inserting a resized inner patch into the center of an outer patch. This visualization grid helps in comparing the reference and input images in a structured manner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ls_mean_ref
|
np.ndarray
|
List of outer image patches. Each patch is repeated to form the full grid background. |
required |
ls_mean_in
|
np.ndarray
|
List of inner image patches meant to be resized and placed into the center of the outer patches. |
required |
patch_size
|
tuple[int, int, int]t
|
A tuple specifying the size of the patch in the format (height, width, channels) by default (100, 100, 1). |
(100, 100, 1)
|
Returns:
Type | Description |
---|---|
np.ndarray
|
The final composited image with each outer patch modified with the corresponding resized inner patch, arranged in a grid format. |