Ocean
Ocean::CV::ContrastLimitedAdaptiveHistogram Class Reference

Implementation of Contrast-Limited Adaptive Histogram Equalization (CLAHE). More...

Inheritance diagram for Ocean::CV::ContrastLimitedAdaptiveHistogram:

Public Types

typedef std::array< unsigned int, histogramSizeTileHistogram
 Tile histogram. More...
 
typedef LookupCenter2< uint8_t > TileLookupCenter2
 Image partitioning and tile boundary lookup. More...
 

Static Public Member Functions

static void equalization8BitPerChannel (const uint8_t *const source, const unsigned int width, const unsigned height, uint8_t *const target, const Scalar clipLimit=Scalar(40), const unsigned int horizontalTiles=8u, const unsigned int verticalTiles=8u, const unsigned int sourcePaddingElements=0u, const unsigned int targetPaddingElements=0u, Worker *worker=nullptr)
 Histogram equalization a la CLAHE. More...
 

Static Public Attributes

static constexpr unsigned int histogramSize = 256u
 Number of bins in the tile histograms. More...
 

Static Protected Member Functions

static void computeLookupTable (const uint8_t *source, const unsigned int width, const unsigned int height, uint8_t *const lookupTable, const Scalar clipLimit, const unsigned int sourcePaddingElements=0u)
 Computation of a lookup table required to normalize an image histogram (used per tile) More...
 
static void computeTileLookupTables (const uint8_t *const source, const TileLookupCenter2 &lookupCenter2, std::vector< uint8_t > &tileLookupTables, const Scalar clipLimit, const unsigned int sourcePaddingElements=0u, Worker *worker=nullptr)
 Computation of per-tile lookup tables required to normalize an image histogram given a partitioned image. More...
 
static void computeLowBilinearInterpolationFactors7BitPrecision (const TileLookupCenter2 &lookupCenter2, const bool isHorizontal, Index32 *lowBins, uint8_t *lowFactors_fixed7)
 Computation of the bilinear interpolation parameters for the low bins of an image pixel If isHorizontal == true, this function computes the horizontal interpolation parameters, i.e., the left bins and left interpolation factors, otherwise it will compute the top bins and interpolation factors. More...
 
static void bilinearInterpolation (const uint8_t *const source, const TileLookupCenter2 &lookupCenter2, uint8_t *const target, const std::vector< uint8_t > &tileLookupTables, const unsigned int sourcePaddingElements=0u, const unsigned int targetPaddingElements=0u, Worker *worker=nullptr)
 Histogram normalization by bilinearly interpolating pixels using the CLAHE per-tile lookup tables. More...
 
static void computeTileLookupTablesSubset (const uint8_t *const source, const TileLookupCenter2 *lookupCenter2, uint8_t *const tileLookupTables, const Scalar clipLimit, const unsigned int sourcePaddingElements=0u, const unsigned int firstTile=0u, const unsigned int tileCount=0u)
 Helper function for the computation of per-tile lookup tables required to normalize an image histogram given a partitioned image. More...
 
static void bilinearInterpolation7BitPrecisionSubset (const uint8_t *const source, const TileLookupCenter2 *lookupCenter2, uint8_t *const target, const uint8_t *const tileLookupTables, const Index32 *const leftBins, const uint8_t *const leftFactors_fixed7, const unsigned int sourcePaddingElements=0u, const unsigned int targetPaddingElements=0u, const unsigned int rowStart=0u, const unsigned int rowCount=0u)
 Integer-based (fixed-point arithmetic) helper function for the histogram normalization by bilinearly interpolating pixels using the CLAHE per-tile lookup tables. More...
 
static void bilinearInterpolationNEON7BitPrecisionSubset (const uint8_t *const source, const TileLookupCenter2 *lookupCenter2, uint8_t *const target, const uint8_t *const tileLookupTables, const Index32 *const leftBins, const uint8_t *const leftFactors_fixed7, const Index32 *const topBins, const uint8_t *const topFactors_fixed7, const unsigned int sourcePaddingElements=0u, const unsigned int targetPaddingElements=0u, const unsigned int tileStart=0u, const unsigned int tileCount=0u)
 Helper function for the histogram normalization by bilinearly interpolating pixels using the CLAHE per-tile lookup tables. More...
 

Detailed Description

Implementation of Contrast-Limited Adaptive Histogram Equalization (CLAHE).

Member Typedef Documentation

◆ TileHistogram

Tile histogram.

◆ TileLookupCenter2

Image partitioning and tile boundary lookup.

Member Function Documentation

◆ bilinearInterpolation()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::bilinearInterpolation ( const uint8_t *const  source,
const TileLookupCenter2 lookupCenter2,
uint8_t *const  target,
const std::vector< uint8_t > &  tileLookupTables,
const unsigned int  sourcePaddingElements = 0u,
const unsigned int  targetPaddingElements = 0u,
Worker worker = nullptr 
)
staticprotected

Histogram normalization by bilinearly interpolating pixels using the CLAHE per-tile lookup tables.

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
lookupCenter2Defines how the source frame is partitioned, image size and number of bins will be extracted from this object, must be valid
targetPointer to the data of the target frame, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
tileLookupTablesStorage location for the computed lookup tables; will be initialized internally to size N x 256, where N = the total number of bins
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0
targetPaddingElementsNumber of padding elements in the target data, range: [0, infinity), default: 0
workerOptional worker instance for parallel execution, default: nullptr

◆ bilinearInterpolation7BitPrecisionSubset()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::bilinearInterpolation7BitPrecisionSubset ( const uint8_t *const  source,
const TileLookupCenter2 lookupCenter2,
uint8_t *const  target,
const uint8_t *const  tileLookupTables,
const Index32 *const  leftBins,
const uint8_t *const  leftFactors_fixed7,
const unsigned int  sourcePaddingElements = 0u,
const unsigned int  targetPaddingElements = 0u,
const unsigned int  rowStart = 0u,
const unsigned int  rowCount = 0u 
)
staticprotected

Integer-based (fixed-point arithmetic) helper function for the histogram normalization by bilinearly interpolating pixels using the CLAHE per-tile lookup tables.

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
lookupCenter2Defines how the source frame is partitioned, image size and number of bins will be extracted from this object, must be valid
targetPointer to the data of the target frame, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
tileLookupTablesStorage location for the computed lookup tables; will be initialized internally to size N x 256, where N = the total number of bins
leftBinsStores the indices of the closest bins left of a horizontal pixel location, must be initialized, expected size: image width
leftFactors_fixed7Stores the horizontal interpolation factors for the left bins (as fixed-point number with 7-bit precision), must be initialized, expected size: image width
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0
targetPaddingElementsNumber of padding elements in the target data, range: [0, infinity), default: 0
rowStartFirst image row to process, range: [0, height)
rowCountNumber of rows to process, range: [0, height - rowStart)

◆ bilinearInterpolationNEON7BitPrecisionSubset()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::bilinearInterpolationNEON7BitPrecisionSubset ( const uint8_t *const  source,
const TileLookupCenter2 lookupCenter2,
uint8_t *const  target,
const uint8_t *const  tileLookupTables,
const Index32 *const  leftBins,
const uint8_t *const  leftFactors_fixed7,
const Index32 *const  topBins,
const uint8_t *const  topFactors_fixed7,
const unsigned int  sourcePaddingElements = 0u,
const unsigned int  targetPaddingElements = 0u,
const unsigned int  tileStart = 0u,
const unsigned int  tileCount = 0u 
)
staticprotected

Helper function for the histogram normalization by bilinearly interpolating pixels using the CLAHE per-tile lookup tables.

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
lookupCenter2Defines how the source frame is partitioned, image size and number of bins will be extracted from this object, must be valid
targetPointer to the data of the target frame, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
tileLookupTablesStorage location for the computed lookup tables; will be initialized internally to size N x 256, where N = the total number of bins
leftBinsStores the indices of the closest bins left of a horizontal pixel location, must be initialized, expected size: image width
leftFactors_fixed7Stores the horizontal interpolation factors for the left bins (as fixed-point number with 7-bit precision), must be initialized, expected size: image width
topBinsStores the indices of the closest vertical bins above a pixel location, must be initialized, expected size: image height
topFactors_fixed7Stores the vertical interpolation factors for the top bins (as fixed-point number with 7-bit precision), must be initialized, expected size: image height
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0
targetPaddingElementsNumber of padding elements in the target data, range: [0, infinity), default: 0
tileStartFirst tile to process, range: [0, N), where N = number of tiles
tileCountNumber of tiles to process, range: [0, N - tileStart)

◆ computeLookupTable()

void Ocean::CV::ContrastLimitedAdaptiveHistogram::computeLookupTable ( const uint8_t *  source,
const unsigned int  width,
const unsigned int  height,
uint8_t *const  lookupTable,
const Scalar  clipLimit,
const unsigned int  sourcePaddingElements = 0u 
)
inlinestaticprotected

Computation of a lookup table required to normalize an image histogram (used per tile)

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
widthThe width of the source and target frames, range: [1, infinity)
heightThe height of the source and target frames, range: [1, infinity)
lookupTableStorage location for the computed lookup table, must be initialized, expected size: 256
clipLimitScaling factor to determine the tile clip limit, tileClipLimit = clipLimit * N, where N = (tileSize / histogramSize) is the number of pixels per bin if all pixels are distributed evenly over the histogram (average), range: [0, infinity)
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0

◆ computeLowBilinearInterpolationFactors7BitPrecision()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::computeLowBilinearInterpolationFactors7BitPrecision ( const TileLookupCenter2 lookupCenter2,
const bool  isHorizontal,
Index32 lowBins,
uint8_t *  lowFactors_fixed7 
)
staticprotected

Computation of the bilinear interpolation parameters for the low bins of an image pixel If isHorizontal == true, this function computes the horizontal interpolation parameters, i.e., the left bins and left interpolation factors, otherwise it will compute the top bins and interpolation factors.

For the horizontal parameters (isHorizontal == true), the right counterparts can be computed as:

rightBins[i] = lowBins[i] + 1u rightFactors_fixed7[i] = 128u - lowFactors_fixed7[i]

and, similarly, for the vertical parameters (isHorizontal == false).

Note: 128u is the fixed-point, 7-bit precision equivalent of 1.0f

Parameters
lookupCenter2Defines how the source frame is partitioned, image size and number of bins will be extracted from this object, must be valid, number of bins (binsX()) must >= 2
isHorizontalIf true, it will compute the horizontal interpolation parameters, otherwise the vertical parameters will be computed
lowBinsStores the indices of the closest lower (lower = left if isHorizontal == true, otherwise lower = top) bins of a pixel location, must be initialized before calling this function, expected size: image width if isHorizontal == true, otherwise image height
lowFactors_fixed7Stores the horizontal (if isHorizontal == true) or vertical (if isHorizontal == false) interpolation factors for the lower bins (as 8-bit fixed point numbers with 7-bit precision, i.e. range: [0, 1]), must be initialized before calling this function, expected size: image width if isHorizontal == true, otherwise image height

◆ computeTileLookupTables()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::computeTileLookupTables ( const uint8_t *const  source,
const TileLookupCenter2 lookupCenter2,
std::vector< uint8_t > &  tileLookupTables,
const Scalar  clipLimit,
const unsigned int  sourcePaddingElements = 0u,
Worker worker = nullptr 
)
staticprotected

Computation of per-tile lookup tables required to normalize an image histogram given a partitioned image.

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
lookupCenter2Defines how the source frame is partitioned, image size and number of bins will be extracted from this object, must be valid
tileLookupTablesStorage location for the computed lookup tables; will be initialized internally to size N x 256, where N = the total number of bins
clipLimitScaling factor to determine the tile clip limit, tileClipLimit = clipLimit * N, where N = (tileSize / histogramSize) is the number of pixels per bin if all pixels are distributed evenly over the histogram (average), range: [0, infinity)
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0
workerOptional worker instance for parallel execution, default: nullptr

◆ computeTileLookupTablesSubset()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::computeTileLookupTablesSubset ( const uint8_t *const  source,
const TileLookupCenter2 lookupCenter2,
uint8_t *const  tileLookupTables,
const Scalar  clipLimit,
const unsigned int  sourcePaddingElements = 0u,
const unsigned int  firstTile = 0u,
const unsigned int  tileCount = 0u 
)
staticprotected

Helper function for the computation of per-tile lookup tables required to normalize an image histogram given a partitioned image.

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
lookupCenter2Defines how the source frame is partitioned, image size and number of bins will be extracted from this object, must be valid
tileLookupTablesStorage location for the computed lookup tables; will be initialized internally to size N x 256, where N = the total number of bins
clipLimitScaling factor to determine the tile clip limit, tileClipLimit = clipLimit * N, where N = (tileSize / histogramSize) is the number of pixels per bin if all pixels are distributed evenly over the histogram (average), range: [0, infinity)
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0
firstTileIndex of first tile to process, range: [0, N), where N is the total number of tiles
tileCountNumber of tiles to process, range: [1, N], such firstTile + tileCount < N where N is the total number of tiles

◆ equalization8BitPerChannel()

static void Ocean::CV::ContrastLimitedAdaptiveHistogram::equalization8BitPerChannel ( const uint8_t *const  source,
const unsigned int  width,
const unsigned  height,
uint8_t *const  target,
const Scalar  clipLimit = Scalar(40),
const unsigned int  horizontalTiles = 8u,
const unsigned int  verticalTiles = 8u,
const unsigned int  sourcePaddingElements = 0u,
const unsigned int  targetPaddingElements = 0u,
Worker worker = nullptr 
)
static

Histogram equalization a la CLAHE.

Parameters
sourcePointer to the data of the source frame that will be processed, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8)
widthThe width of the source and target frames, range: [horizontalTiles, infinity)
heightThe height of the source and target frames, range: [verticalTiles, infinity)
targetDestination location for the result, must be valid and 8-bit unsigned, 1-channel (FrameType::FORMAT_Y8) and have the same size as the source
clipLimitGlobal scaling factor to determine the tile clip limit, tileClipLimit = clipLimit * N, where N = (tileSize / histogramSize) is the number of pixels per bin if all pixels are distributed evenly over the histogram (average), range: [0, infinity), default: 40
horizontalTilesNumber of tiles the source image will be split horizontally, range: [2, width], default: 8
verticalTilesNumber of tiles the source image will be split vertically, range: [2, height], default: 8
sourcePaddingElementsNumber of padding elements in the source data, range: [0, infinity), default: 0
targetPaddingElementsNumber of padding elements in the target data, range: [0, infinity), default: 0
workerOptional worker instance for parallel execution, default: nullptr

Field Documentation

◆ histogramSize

constexpr unsigned int Ocean::CV::ContrastLimitedAdaptiveHistogram::histogramSize = 256u
staticconstexpr

Number of bins in the tile histograms.


The documentation for this class was generated from the following file: