Clahe3d
Performs a contrast limited adaptive histogram equalization (CLAHE) on a three-dimensional image.
Access to parameter description
The Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm is a widely used method for locally enhancing the contrast of images. It improves the visibility of details in low-contrast images by assigning each pixel an output value based on a transformation function derived from the histogram of a surrounding tile.
Homegenous regions can generate strong peaks in the histogram. Applying equalization to such histograms tends to over-amplify noise. To address this, a contrast limiting mechanism is applied, which truncates the histogram of each tile at a specified clip limit. If a histogram bin exceeds this limit, the corresponding pixel intensities are redistributed uniformly among other bins.
The maximum number of elements $M$ in a histogram bin is given by: $$ M = Cl \times \frac{P}{N} $$ Where:
By default, the histograms are computed only on contiguous tiles, providing accurate results for each tile center. Other pixel values are computed by interpolating the histograms computed for overlapping tiles. Alternatively, the actual histogram of each image pixel can be computed by changing the computationMode parameter. The first method is faster, while the second is more accurate.
The CLAHE algorithm can be sumarized by the following steps:
K.Zuiderveld. "Contrast Limited Adaptive Histogram Equalization". Graphics Gems IV, pp.474-485, 1994.
See also
Access to parameter description
The Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm is a widely used method for locally enhancing the contrast of images. It improves the visibility of details in low-contrast images by assigning each pixel an output value based on a transformation function derived from the histogram of a surrounding tile.
Homegenous regions can generate strong peaks in the histogram. Applying equalization to such histograms tends to over-amplify noise. To address this, a contrast limiting mechanism is applied, which truncates the histogram of each tile at a specified clip limit. If a histogram bin exceeds this limit, the corresponding pixel intensities are redistributed uniformly among other bins.
The maximum number of elements $M$ in a histogram bin is given by: $$ M = Cl \times \frac{P}{N} $$ Where:
- $Cl$ is the clipLimit parameter.
- $P$ is the number of pixels contained in a tile, given by the tileSize parameter.
- $N$ is the number of bins, given by numberOfBins parameter.
- $P/N$ is the average histogram content.
By default, the histograms are computed only on contiguous tiles, providing accurate results for each tile center. Other pixel values are computed by interpolating the histograms computed for overlapping tiles. Alternatively, the actual histogram of each image pixel can be computed by changing the computationMode parameter. The first method is faster, while the second is more accurate.
The CLAHE algorithm can be sumarized by the following steps:
- Divide the image into tiles of a fixed size.
- Compute the histogram for each tile.
- Clip the histograms, if necessary.
- Perform a histogram equalization on each tile.
K.Zuiderveld. "Contrast Limited Adaptive Histogram Equalization". Graphics Gems IV, pp.474-485, 1994.
See also
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > clahe3d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector3u32 tileSize, Clahe3d::ComputationMode computationMode, double clipLimit, uint32_t numberOfBins, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype. clahe_3d(input_image: idt.ImageType, tile_size: Iterable[int] = [64, 64, 64], computation_mode: Clahe3d.ComputationMode = Clahe3d.ComputationMode.INTERPOLATED, clip_limit: float = 1, number_of_bins: int = 256, output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype. public static IOLink.ImageView Clahe3d( IOLink.ImageView inputImage, uint[] tileSize = null, Clahe3d.ComputationMode computationMode = ImageDev.Clahe3d.ComputationMode.INTERPOLATED, double clipLimit = 1, UInt32 numberOfBins = 256, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image. | Image | Grayscale or Multispectral | nullptr | |||||
tileSize |
The X, Y and Z size, in pixels, of the tile used to compute the histogram. | Vector3u32 | Any value | {64, 64, 64} | |||||
computationMode |
The way to compute histograms for the transformation function.
|
Enumeration | INTERPOLATED | ||||||
clipLimit |
The ratio defining the maximum number of elements contained in a histogram bin as a multiple of the average histogram contents.
This maximum number of elements is equal to the clip limit multiplied by the number of pixels of a tile divided by the number of bins of the histogram.
|
Float64 | >=0 | 1 | |||||
numberOfBins |
The number of bins of the histogram. | UInt32 | >=1 | 256 | |||||
outputImage |
The output image. The output image characteristics are forced to the same as the input image. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
input_image |
The input image. | image | Grayscale or Multispectral | None | |||||
tile_size |
The X, Y and Z size, in pixels, of the tile used to compute the histogram. | vector3u32 | Any value | [64, 64, 64] | |||||
computation_mode |
The way to compute histograms for the transformation function.
|
enumeration | INTERPOLATED | ||||||
clip_limit |
The ratio defining the maximum number of elements contained in a histogram bin as a multiple of the average histogram contents.
This maximum number of elements is equal to the clip limit multiplied by the number of pixels of a tile divided by the number of bins of the histogram.
|
float64 | >=0 | 1 | |||||
number_of_bins |
The number of bins of the histogram. | uint32 | >=1 | 256 | |||||
output_image |
The output image. The output image characteristics are forced to the same as the input image. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image. | Image | Grayscale or Multispectral | null | |||||
tileSize |
The X, Y and Z size, in pixels, of the tile used to compute the histogram. | Vector3u32 | Any value | {64, 64, 64} | |||||
computationMode |
The way to compute histograms for the transformation function.
|
Enumeration | INTERPOLATED | ||||||
clipLimit |
The ratio defining the maximum number of elements contained in a histogram bin as a multiple of the average histogram contents.
This maximum number of elements is equal to the clip limit multiplied by the number of pixels of a tile divided by the number of bins of the histogram.
|
Float64 | >=0 | 1 | |||||
numberOfBins |
The number of bins of the histogram. | UInt32 | >=1 | 256 | |||||
outputImage |
The output image. The output image characteristics are forced to the same as the input image. | Image | null |
Object Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); Clahe3d clahe3dAlgo; clahe3dAlgo.setInputImage( foam ); clahe3dAlgo.setTileSize( {32, 32, 32} ); clahe3dAlgo.setComputationMode( Clahe3d::ComputationMode::INTERPOLATED ); clahe3dAlgo.setClipLimit( 3 ); clahe3dAlgo.setNumberOfBins( 256 ); clahe3dAlgo.execute(); std::cout << "outputImage:" << clahe3dAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) clahe_3d_algo = imagedev.Clahe3d() clahe_3d_algo.input_image = foam clahe_3d_algo.tile_size = [32, 32, 32] clahe_3d_algo.computation_mode = imagedev.Clahe3d.INTERPOLATED clahe_3d_algo.clip_limit = 3 clahe_3d_algo.number_of_bins = 256 clahe_3d_algo.execute() print("output_image:", str(clahe_3d_algo.output_image))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); Clahe3d clahe3dAlgo = new Clahe3d { inputImage = foam, tileSize = new uint[]{32, 32, 32}, computationMode = Clahe3d.ComputationMode.INTERPOLATED, clipLimit = 3, numberOfBins = 256 }; clahe3dAlgo.Execute(); Console.WriteLine( "outputImage:" + clahe3dAlgo.outputImage.ToString() );
Function Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto result = clahe3d( foam, {32, 32, 32}, Clahe3d::ComputationMode::INTERPOLATED, 3, 256 ); std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) result = imagedev.clahe_3d(foam, [32, 32, 32], imagedev.Clahe3d.INTERPOLATED, 3, 256) print("output_image:", str(result))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); IOLink.ImageView result = Processing.Clahe3d( foam, new uint[]{32, 32, 32}, Clahe3d.ComputationMode.INTERPOLATED, 3, 256 ); Console.WriteLine( "outputImage:" + result.ToString() );