|
| 1 | +Help on class Equalization in module keras.src.layers.preprocessing.image_preprocessing.equalization: |
| 2 | + |
| 3 | +class Equalization(keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer.BaseImagePreprocessingLayer) |
| 4 | + | Equalization(value_range=(0, 255), bins=256, data_format=None, **kwargs) |
| 5 | + | |
| 6 | + | Preprocessing layer for histogram equalization on image channels. |
| 7 | + | |
| 8 | + | Histogram equalization is a technique to adjust image intensities to |
| 9 | + | enhance contrast by effectively spreading out the most frequent |
| 10 | + | intensity values. This layer applies equalization on a channel-wise |
| 11 | + | basis, which can improve the visibility of details in images. |
| 12 | + | |
| 13 | + | This layer works with both grayscale and color images, performing |
| 14 | + | equalization independently on each color channel. At inference time, |
| 15 | + | the equalization is consistently applied. |
| 16 | + | |
| 17 | + | **Note:** This layer is safe to use inside a `tf.data` pipeline |
| 18 | + | (independently of which backend you're using). |
| 19 | + | |
| 20 | + | Args: |
| 21 | + | value_range: Optional list/tuple of 2 floats specifying the lower |
| 22 | + | and upper limits of the input data values. Defaults to `[0, 255]`. |
| 23 | + | If the input image has been scaled, use the appropriate range |
| 24 | + | (e.g., `[0.0, 1.0]`). The equalization will be scaled to this |
| 25 | + | range, and output values will be clipped accordingly. |
| 26 | + | bins: Integer specifying the number of histogram bins to use for |
| 27 | + | equalization. Defaults to 256, which is suitable for 8-bit images. |
| 28 | + | Larger values can provide more granular intensity redistribution. |
| 29 | + | |
| 30 | + | Input shape: |
| 31 | + | 3D (unbatched) or 4D (batched) tensor with shape: |
| 32 | + | `(..., height, width, channels)`, in `"channels_last"` format, |
| 33 | + | or `(..., channels, height, width)`, in `"channels_first"` format. |
| 34 | + | |
| 35 | + | Output shape: |
| 36 | + | 3D (unbatched) or 4D (batched) tensor with shape: |
| 37 | + | `(..., target_height, target_width, channels)`, |
| 38 | + | or `(..., channels, target_height, target_width)`, |
| 39 | + | in `"channels_first"` format. |
| 40 | + | |
| 41 | + | Example: |
| 42 | + | |
| 43 | + | ```python |
| 44 | + | # Create an equalization layer for standard 8-bit images |
| 45 | + | equalizer = keras.layers.Equalization() |
| 46 | + | |
| 47 | + | # An image with uneven intensity distribution |
| 48 | + | image = [...] # your input image |
| 49 | + | |
| 50 | + | # Apply histogram equalization |
| 51 | + | equalized_image = equalizer(image) |
| 52 | + | |
| 53 | + | # For images with custom value range |
| 54 | + | custom_equalizer = keras.layers.Equalization( |
| 55 | + | value_range=[0.0, 1.0], # for normalized images |
| 56 | + | bins=128 # fewer bins for more subtle equalization |
| 57 | + | ) |
| 58 | + | custom_equalized = custom_equalizer(normalized_image) |
| 59 | + | ``` |
| 60 | + | |
| 61 | + | Method resolution order: |
| 62 | + | Equalization |
| 63 | + | keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer.BaseImagePreprocessingLayer |
| 64 | + | keras.src.layers.preprocessing.tf_data_layer.TFDataLayer |
| 65 | + | keras.src.layers.layer.Layer |
| 66 | + | keras.src.backend.tensorflow.layer.TFLayer |
| 67 | + | keras.src.backend.tensorflow.trackable.KerasAutoTrackable |
| 68 | + | tensorflow.python.trackable.autotrackable.AutoTrackable |
| 69 | + | tensorflow.python.trackable.base.Trackable |
| 70 | + | keras.src.ops.operation.Operation |
| 71 | + | keras.src.saving.keras_saveable.KerasSaveable |
| 72 | + | builtins.object |
| 73 | + | |
| 74 | + | Methods defined here: |
| 75 | + | |
| 76 | + | __init__( |
| 77 | + | self, |
| 78 | + | value_range=(0, 255), |
| 79 | + | bins=256, |
| 80 | + | data_format=None, |
| 81 | + | **kwargs |
| 82 | + | ) |
| 83 | + | Initialize self. See help(type(self)) for accurate signature. |
| 84 | + | |
| 85 | + | compute_output_shape(self, input_shape) |
| 86 | + | |
| 87 | + | compute_output_spec( |
| 88 | + | self, |
| 89 | + | inputs, |
| 90 | + | **kwargs |
| 91 | + | ) |
| 92 | + | |
| 93 | + | get_config(self) |
| 94 | + | Returns the config of the object. |
| 95 | + | |
| 96 | + | An object config is a Python dictionary (serializable) |
| 97 | + | containing the information needed to re-instantiate it. |
| 98 | + | |
| 99 | + | transform_bounding_boxes( |
| 100 | + | self, |
| 101 | + | bounding_boxes, |
| 102 | + | transformation, |
| 103 | + | training=True |
| 104 | + | ) |
| 105 | + | |
| 106 | + | transform_images( |
| 107 | + | self, |
| 108 | + | images, |
| 109 | + | transformation, |
| 110 | + | training=True |
| 111 | + | ) |
| 112 | + | |
| 113 | + | transform_labels( |
| 114 | + | self, |
| 115 | + | labels, |
| 116 | + | transformation, |
| 117 | + | training=True |
| 118 | + | ) |
| 119 | + | |
| 120 | + | transform_segmentation_masks( |
| 121 | + | self, |
| 122 | + | segmentation_masks, |
| 123 | + | transformation, |
| 124 | + | training=True |
| 125 | + | ) |
| 126 | + | |
| 127 | + |
0 commit comments