View source on GitHub
|
Preprocessing layer for histogram equalization on image channels.
Inherits From: Layer, Operation
tf.keras.layers.Equalization(
value_range=(0, 255), bins=256, data_format=None, **kwargs
)
Histogram equalization is a technique to adjust image intensities to enhance contrast by effectively spreading out the most frequent intensity values. This layer applies equalization on a channel-wise basis, which can improve the visibility of details in images.
This layer works with both grayscale and color images, performing equalization independently on each color channel. At inference time, the equalization is consistently applied.
Input shape | |
|---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Output shape | |
|---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Example:
# Create an equalization layer for standard 8-bit images
equalizer = keras.layers.Equalization()
# An image with uneven intensity distribution
image = [...] # your input image
# Apply histogram equalization
equalized_image = equalizer(image)
# For images with custom value range
custom_equalizer = keras.layers.Equalization(
value_range=[0.0, 1.0], # for normalized images
bins=128 # fewer bins for more subtle equalization
)
custom_equalized = custom_equalizer(normalized_image)
Methods
convert_weight
convert_weight(
weight
)
Convert the weight if it is from the a different backend.
from_config
@classmethodfrom_config( config )
Creates an operation from its config.
This method is the reverse of get_config, capable of instantiating the
same operation from the config dictionary.
if "dtype" in config and isinstance(config["dtype"], dict):
policy = dtype_policies.deserialize(config["dtype"])
| Args | |
|---|---|
config
|
A Python dictionary, typically the output of get_config.
|
| Returns | |
|---|---|
| An operation instance. |
get_random_transformation
get_random_transformation(
data, training=True, seed=None
)
transform_bounding_boxes
transform_bounding_boxes(
bounding_boxes, transformation, training=True
)
transform_images
transform_images(
images, transformation, training=True
)
transform_labels
transform_labels(
labels, transformation, training=True
)
transform_segmentation_masks
transform_segmentation_masks(
segmentation_masks, transformation, training=True
)
transform_single_bounding_box
transform_single_bounding_box(
bounding_box, transformation, training=True
)
transform_single_image
transform_single_image(
image, transformation, training=True
)
transform_single_label
transform_single_label(
label, transformation, training=True
)
transform_single_segmentation_mask
transform_single_segmentation_mask(
segmentation_mask, transformation, training=True
)
View source on GitHub