ImageDev

Clahe3d

Performs a contrast limited adaptive histogram equalization (CLAHE) on a three-dimensional image.

Access to parameter description

CLAHE is a technique that locally improves the contrast of an image and homogenizes the luminosity of its regions. It assigns each pixel an output value according to a transformation function based on the histogram of a tile surrounding it. This transformation is exactly the same as for standard histogram equalization and is proportional to the cumulative distribution function (CDF) of pixel values in the neighborhood. Ordinary adaptive histogram equalization tends to overamplify the contrast in near-constant regions of the image, since the histogram in such regions is highly concentrated. As a result, adaptive histogram equalization may cause noise to be amplified in near-constant regions. Contrast limited adaptive histogram equalization is a variant of adaptive histogram equalization in which the contrast amplification is limited, to reduce the problem of noise amplification. The contrast amplification in the proximity of a given pixel value is given by the slope of the transformation function. This transformation function which is proportional to the slope of the neighborhood CDF and therefore to the value of the histogram at that pixel value. CLAHE limits the amplification by clipping the histogram at a predefined value before computing the cumulative distribution function. This limits the slope of the CDF and therefore of the transformation function. The value at which the histogram is clipped, the clip limit, depends on the normalization of the histogram and thereby on the size of the neighborhood region. It is advantageous not to discard the part of the histogram that exceeds the clip limit but to redistribute it equally among all histogram bins.

Reference:
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 = NULL );
This function returns outputImage.
// Function prototype.
clahe_3d( input_image,
          tile_size = [64, 64, 64],
          computation_mode = Clahe3d.ComputationMode.INTERPOLATED,
          clip_limit = 1,
          number_of_bins = 256,
          output_image = None )
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
input
inputImage
The input image. Image Grayscale or Multispectral nullptr
input
tileSize
The X, Y and Z size, in pixels, of the tile used to compute the histogram. Vector3u32 Any value {64, 64, 64}
input
computationMode
The way to compute histograms for the transformation function.
INTERPOLATED The image is divided in contiguous tiles. A histogram is calculated for each tile and the transformation function for a given pixel is determined by interpolation of these histograms.
SLIDING A histogram is computed for the tile surrounding each pixel and the transformation function is based on this histogram.
Enumeration INTERPOLATED
input
clipLimit
The ratio defining the maximum number of elements contained in a histogram bin as a multiple of the average histogram contents. This maximum value is equal to clipLimit x number of elements of a tile / number of bins of the histogram. A value of clipLimit equals to the number of bins of the histogram means no contrast amplification limitation. A value of clipLimit equals to 0 means output image equivalent to input image. Float64 >=0 1
input
numberOfBins
The number of bins of the histogram UInt32 >=1 256
output
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
input_image
The input image. image Grayscale or Multispectral None
input
tile_size
The X, Y and Z size, in pixels, of the tile used to compute the histogram. vector3u32 Any value [64, 64, 64]
input
computation_mode
The way to compute histograms for the transformation function.
INTERPOLATED The image is divided in contiguous tiles. A histogram is calculated for each tile and the transformation function for a given pixel is determined by interpolation of these histograms.
SLIDING A histogram is computed for the tile surrounding each pixel and the transformation function is based on this histogram.
enumeration INTERPOLATED
input
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 value is equal to clipLimit x number of elements of a tile / number of bins of the histogram. A value of clipLimit equals to the number of bins of the histogram means no contrast amplification limitation. A value of clipLimit equals to 0 means output image equivalent to input image. float64 >=0 1
input
number_of_bins
The number of bins of the histogram uint32 >=1 256
output
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
input
inputImage
The input image. Image Grayscale or Multispectral null
input
tileSize
The X, Y and Z size, in pixels, of the tile used to compute the histogram. Vector3u32 Any value {64, 64, 64}
input
computationMode
The way to compute histograms for the transformation function.
INTERPOLATED The image is divided in contiguous tiles. A histogram is calculated for each tile and the transformation function for a given pixel is determined by interpolation of these histograms.
SLIDING A histogram is computed for the tile surrounding each pixel and the transformation function is based on this histogram.
Enumeration INTERPOLATED
input
clipLimit
The ratio defining the maximum number of elements contained in a histogram bin as a multiple of the average histogram contents. This maximum value is equal to clipLimit x number of elements of a tile / number of bins of the histogram. A value of clipLimit equals to the number of bins of the histogram means no contrast amplification limitation. A value of clipLimit equals to 0 means output image equivalent to input image. Float64 >=0 1
input
numberOfBins
The number of bins of the histogram UInt32 >=1 256
output
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() );