tf.keras.layers.ContrastLimitedAdaptiveHistogramEqualization

Contrast Limited Adaptive Histogram Equalization (CLAHE) layer.

Inherits From: Layer, Operation

CLAHE is a variant of Adaptive Histogram Equalization (AHE) which takes care of over-amplification of the contrast. It operates on small regions in the image, called tiles, rather than the entire image. The neighboring tiles are then combined using bilinear interpolation to remove the artificial boundaries. This algorithm can be applied to improve the contrast of an image.

value_range Optional list/tuple of 2 floats specifying the lower and upper limits of the input data values. Defaults to (0, 255).
clip_limit Float. Limits the noise amplification in near-constant regions. Defaults to 4.0.
tile_grid_size Tuple of 2 integers (height, width). Specifies the number of tiles to divide the image into. Defaults to (8, 8).
data_format String, either "channels_last" or "channels_first". The ordering of the dimensions in the inputs. "channels_last" corresponds to inputs with shape (batch, height, width, channels) while "channels_first" corresponds to inputs with shape (batch, channels, height, width). It defaults to the image_data_format value found in your Keras config file at ~/.keras/keras.json. If you never set it, then it will be "channels_last".

3D unbatched) or 4D (batched) tensor with shape

(..., height, width, channels), in "channels_last" format, or (..., channels, height, width), in "channels_first" format.

3D unbatched) or 4D (batched) tensor with shape

(..., height, width, channels), or (..., channels, height, width), in "channels_first" format.

Example:

import keras
import numpy as np

# Create a CLAHE layer with default parameters
clahe = keras.layers.ContrastLimitedAdaptiveHistogramEqualization()

# Apply CLAHE to an image
# image values should be in the range[0, 255] by default
input_image = np.random.randint(0, 256, (1, 256, 256, 3))
output_image = clahe(input_image)

# For normalized images[0, 1]
clahe_normalized=keras.layers.ContrastLimitedAdaptiveHistogramEqualization(
    value_range=(0.0, 1.0)
)
norm_image = np.random.rand(1, 256, 256, 3)
output_norm = clahe_normalized(norm_image)

input Retrieves the input tensor(s) of a symbolic operation.

Only returns the tensor(s) corresponding to the first time the operation was called.

output Retrieves the output tensor(s) of a layer.

Only returns the tensor(s) corresponding to the first time the operation was called.

Methods

convert_weight

View source

Convert the weight if it is from the a different backend.

from_config

View source

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

View source

transform_bounding_boxes

View source

transform_images

View source

transform_labels

View source

transform_segmentation_masks

View source

transform_single_bounding_box

View source

transform_single_image

View source

transform_single_label

View source

transform_single_segmentation_mask

View source