Ocean
Ocean::CV::IntegralImage Class Reference

This class provides functions to create an integral image from a gray scale image. More...

Data Structures

class  Comfort
 The following comfort class provides comfortable functions simplifying prototyping applications but also increasing binary size of the resulting applications. More...
 

Public Member Functions

template<typename TIntegral >
TIntegral linedIntegralSum (const TIntegral *const linedIntegral, const unsigned int linedIntegralStrideElements, const unsigned int windowLeft, const unsigned int windowTop, const unsigned int windowWidth, const unsigned int windowHeight)
 

Static Public Member Functions

template<typename T , typename TIntegral , unsigned int tChannels>
static void createImage (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates an integral image from a given 1-plane image. More...
 
template<typename T , typename TIntegral , unsigned int tChannels>
static void createLinedImage (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates an integral image from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border. More...
 
template<typename T , typename TIntegral , unsigned int tChannels>
static void createLinedImageSquared (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates an integral image with squared pixel intensities from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border. More...
 
template<typename T , typename TIntegralAndSquared , unsigned int tChannels>
static void createLinedImageAndSquared (const T *source, TIntegralAndSquared *integralAndSquared, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralAndSquaredPaddingElements)
 Creates an integral image and squared integral image from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border. More...
 
template<typename T , typename TIntegral , typename TIntegralSquared , unsigned int tChannels>
static void createLinedImageAndSquared (const T *source, TIntegral *integral, TIntegralSquared *integralSquared, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements, const unsigned int integralSquaredPaddingElements)
 Creates an integral image and squared integral image from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border. More...
 
template<typename T , typename TIntegral , unsigned int tChannels>
static void createBorderedImage (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates a bordered integral image from a given 1-plane image and adds an extra border to the resulting integral image. More...
 
template<typename T , typename TIntegral , unsigned int tChannels>
static void createBorderedImageSquared (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates a bordered squared integral image from a given 1-plane image and adds an extra border to the resulting integral image. More...
 
template<typename T , typename TIntegral , unsigned int tChannels>
static void createBorderedImageMirror (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates a bordered integral image from a given 1-plane image and adds an extra border with mirrored image content to the resulting integral image. More...
 
template<typename T , typename TIntegral , unsigned int tChannels>
static void createBorderedImageSquaredMirror (const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates a bordered squared integral image from a given 1-plane image and adds an extra border with mirrored image content to the resulting integral image. More...
 
template<typename TIntegral >
static OCEAN_FORCE_INLINE TIntegral linedIntegralSum (const TIntegral *const linedIntegral, const unsigned int linedIntegralStrideElements, const unsigned int windowLeft, const unsigned int windowTop, const unsigned int windowWidth, const unsigned int windowHeight)
 Determines the sum of elements within a window from an integral image. More...
 
template<typename TIntegral , typename TIntegralSquared , typename TVariance , bool tReturnMean = false>
static TVariance linedIntegralVariance (const TIntegral *linedIntegral, const TIntegralSquared *linedIntegralSquared, const unsigned int integralStrideElements, const unsigned int integralStrideSquaredElements, const unsigned int windowLeft, const unsigned int windowTop, const unsigned int windowWidth, const unsigned int windowHeight, TVariance *mean=nullptr)
 Determines the variance of elements within a window from two integral images. More...
 
template<typename TIntegral , typename TIntegralSquared , typename TVariance , bool tReturnMean = false>
static TVariance linedIntegralVariance (const TIntegral *linedIntegral, const TIntegralSquared *linedIntegralSquared, const unsigned int integralStrideElements, const unsigned int integralStrideSquaredElements, const unsigned int windowALeft, const unsigned int windowATop, const unsigned int windowAWidth, const unsigned int windowAHeight, const unsigned int windowBLeft, const unsigned int windowBTop, const unsigned int windowBWidth, const unsigned int windowBHeight, TVariance *mean=nullptr)
 Determines the variance of elements within two windows from two integral images. More...
 
template<typename TIntegral , typename TIntegralSquared , typename TVariance , bool tReturnMean = false>
static TVariance linedIntegralVariance (const TIntegral *linedIntegral, const TIntegralSquared *linedIntegralSquared, const unsigned int integralStrideElements, const unsigned int integralStrideSquaredElements, const unsigned int windowALeft, const unsigned int windowATop, const unsigned int windowAWidth, const unsigned int windowAHeight, const unsigned int windowBLeft, const unsigned int windowBTop, const unsigned int windowBWidth, const unsigned int windowBHeight, const unsigned int windowCLeft, const unsigned int windowCTop, const unsigned int windowCWidth, const unsigned int windowCHeight, TVariance *mean=nullptr)
 Determines the variance of elements within three windows from two integral images. More...
 

Static Private Member Functions

static void createLinedImage1Channel8BitNEON (const uint8_t *source, uint32_t *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
 Creates an integral image from 8 bit images with 1 channel and adds an extra line with zeros to the left and top image border and applies NEON instructions. More...
 
template<typename T , typename TSquared >
static TSquared sqr (const T &value)
 Returns the square value of the given parameter. More...
 

Detailed Description

This class provides functions to create an integral image from a gray scale image.

Member Function Documentation

◆ createBorderedImage()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createBorderedImage ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  border,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates a bordered integral image from a given 1-plane image and adds an extra border to the resulting integral image.

In case, the given frame has more than one channel, the channels of the resulting integral image will be interleaved (not stored as individual planes).
The resulting integral image has a (non interfering) border.
The bordered integral image has the following scheme:

 ------------------------- ---------
|0000000000000000000000000|         |
|0|-----------------------|         |
|0|     |           |     |         |
|0|  0  |     0     |  0  |         |
|0|     |           |     |         |
|0|-----|-----------|-----|         |
|0|     |           |  >  |         |
|0|     |           |  >  |         |
|0|  0  | Integral  |  >  | padding |
|0|     |           |  >  |         |
|0|     |           |  >  |         |
|0|-----|-----------|-----|         |
|0|     |           |     |         |
|0|  0  |     V     |  V  |         |
|0|     |           |     |         |
 -----------------------------------

Columns or rows with '0' receive a null value.
Rows with '>' receive the last valid integral value from the left.
Rows with 'v' receive the last valid integral value from the top.
Further, additionally to the border, the integral image contains one column at the left border and one row at the top border with zeros.
Therefore, the entire integral image width is: 1 + 2 * border + originalWidth,
and the entire height is: 1 + 2 * border + originalHeight.

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (width + 1 + 2 * border)x(height + 1 + 2 * border), must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
borderThe thickness of the border in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createLinedImage().

This is the resulting bordered integral image. Columns or rows with '0' receive a null value. Rows with '>' receive the last valid integral value from the left

Rows with 'v' receive the last valid integral value from the top

|0000000000000000000000000| |0|--------------------—| |0| | | | |0| 0 | 0 | 0 | |0| | | | |0|--—|--------—|--—| |0| | | > | |0| | | > | |0| 0 | Integral | > | |0| | | > | |0| | | > | |0|--—|--------—|--—| |0| | | | |0| 0 | V | V |

|0| | | |

◆ createBorderedImageMirror()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createBorderedImageMirror ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  border,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates a bordered integral image from a given 1-plane image and adds an extra border with mirrored image content to the resulting integral image.

The resulting integral image has an extra border created from the original frame with mirrored border pixels.
Additionally, independent from the border size, the integral image contains one column at the left border and one row at the top border with zeros.
Therefore, the entire integral image width is: 1 + 2 * border + originalWidth,
and the entire height is: 1 + 2 * border + originalHeight.
The bordered integral image has the following scheme:

 ------------------------- ---------
|0000000000000000000000000|         |
|0|-----------------------|         |
|0|     |           |     |         |
|0|  m  |  mirrored |  m  |         |
|0|     |           |     |         |
|0|-----|-----------|-----|         |
|0|     |           |     |         |
|0|     |           |     |         |
|0|  m  | Integral  |  m  | padding |
|0|     |           |     |         |
|0|     |           |     |         |
|0|-----|-----------|-----|         |
|0|     |           |     |         |
|0|  m  |  mirrored |  m  |         |
|0|     |           |     |         |
 -----------------------------------
Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (1 + border + width)x(1 + border + height), must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
borderThe thickness of the border in pixel, with range [1, min(width, height)]
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)

This is the resulting bordered integral image.

Columns or rows with '0' receive a null value.

|0000000000000000000000000| |0|--------------------—| |0| | | | |0| m | mirrored | m | |0| | | | |0|--—|--------—|--—| |0| | | | |0| | | | |0| m | Integral | m | |0| | | | |0| | | | |0|--—|--------—|--—| |0| | | | |0| m | mirrored | m |

|0| | | |

◆ createBorderedImageSquared()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createBorderedImageSquared ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  border,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates a bordered squared integral image from a given 1-plane image and adds an extra border to the resulting integral image.

In case, the given frame has more than one channel, the channels of the resulting integral image will be interleaved (not stored as individual planes).
The resulting integral image has a (non interfering) border.
The bordered integral image has the following scheme:

 -------------------------- ---------
|00000000000000000000000000|         |
|0|------------------------|         |
|0|     |            |     |         |
|0|  0  |     0      |  0  |         |
|0|     |            |     |         |
|0|-----|------------|-----|         |
|0|     |            |  >  |         |
|0|     |            |  >  |         |
|0|  0  | Integral^2 |  >  | padding |
|0|     |            |  >  |         |
|0|     |            |  >  |         |
|0|-----|------------|-----|         |
|0|     |            |     |         |
|0|  0  |     V      |  V  |         |
|0|     |            |     |         |
 ------------------------------------

Columns or rows with '0' receive a null value.
Rows with '>' receive the last valid integral value from the left.
Rows with 'v' receive the last valid integral value from the top.
Further, additionally to the border, the integral image contains one column at the left border and one row at the top border with zeros.
Therefore, the entire integral image width is: 1 + 2 * border + originalWidth,
and the entire height is: 1 + 2 * border + originalHeight.

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (width + 1)x(height + 1), must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
borderThe thickness of the border in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createLinedImage().

This is the resulting bordered integral image. Columns or rows with '0' receive a null value. Rows with '>' receive the last valid integral value from the left

Rows with 'v' receive the last valid integral value from the top

|00000000000000000000000000| |0|---------------------—| |0| | | | |0| 0 | 0 | 0 | |0| | | | |0|--—|---------—|--—| |0| | | > | |0| | | > | |0| 0 | Integral^2 | > | |0| | | > | |0| | | > | |0|--—|---------—|--—| |0| | | | |0| 0 | V | V |

|0| | | |

◆ createBorderedImageSquaredMirror()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createBorderedImageSquaredMirror ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  border,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates a bordered squared integral image from a given 1-plane image and adds an extra border with mirrored image content to the resulting integral image.

The resulting integral image has an extra border created from the original frame with mirrored border pixels.
Additionally, independent from the border size, the integral image contains one column at the left border and one row at the top border with zeros.
Therefore, the entire integral image width is: 1 + 2 * border + originalWidth,
and the entire height is: 1 + 2 * border + originalHeight.
The bordered integral image has the following scheme:

 ------------------------------- ---------
|0000000000000000000000000000000|         |
|0|-----------------------------|         |
|0|       |             |       |         |
|0|  m^2  |  mirrored^2 |  m^2  |         |
|0|       |             |       |         |
|0|-------|-------------|-------|         |
|0|       |             |       |         |
|0|       |             |       |         |
|0|  m^2  | Integral^2  |  m^2  | padding |
|0|       |             |       |         |
|0|       |             |       |         |
|0|-------|-------------|-------|         |
|0|       |             |       |         |
|0|  m^2  |  mirrored^2 |  m^2  |         |
|0|       |             |       |         |
 -----------------------------------------
Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (1 + border + width)x(1 + border + height), must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
borderThe thickness of the border in pixel, with range [1, min(width, height)]
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)

This is the resulting bordered integral image.

Columns or rows with '0' receive a null value.

|0000000000000000000000000000000| |0|--------------------------—| |0| | | | |0| m^2 | mirrored^2 | m^2 | |0| | | | |0|----—|----------—|----—| |0| | | | |0| | | | |0| m^2 | Integral^2 | m^2 | |0| | | | |0| | | | |0|----—|----------—|----—| |0| | | | |0| m^2 | mirrored^2 | m^2 |

|0| | | |

◆ createImage()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createImage ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates an integral image from a given 1-plane image.

The resulting integral image will have the same resolution as the given image (without any extra borders).
In case, the given frame has more than one channel, the channels of the resulting integral image will be interleaved (not stored as individual planes).
The resulting integral image has the following scheme:

 ---------- ---------
|          |         |
| Integral | padding |
|          |         |
 ---------- ---------

The resolution of the integral image is: width x height.

Parameters
sourceThe source frame for which the integral image will be created, must be valid
integralThe target integral image, must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createLinedImage().

◆ createLinedImage()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createLinedImage ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates an integral image from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border.

In case, the given frame has more than one channel, the channels of the resulting integral image will be interleaved (not stored as individual planes).
The resulting lined integral image has the following scheme:

 ------------ ---------
|000000000000|         |
|0|----------|         |
|0|          | padding |
|0| Integral |         |
|0|          |         |
 ------------ ---------

The resolution of the integral image is: (width + 1)x(height + 1).

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (width + 1)x(height + 1), must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createImage(), createBorderedImage().

◆ createLinedImage1Channel8BitNEON()

static void Ocean::CV::IntegralImage::createLinedImage1Channel8BitNEON ( const uint8_t *  source,
uint32_t *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
staticprivate

Creates an integral image from 8 bit images with 1 channel and adds an extra line with zeros to the left and top image border and applies NEON instructions.

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (width + 1)x(height + 1), must be valid
widthThe width of the given image in pixel, with range [8, 4096^2]
heightThe height of the given image in pixel, with range [1, 4096^2 / width]
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
See also
createLinedImage8BitPerChannel<tChannels>().

◆ createLinedImageAndSquared() [1/2]

template<typename T , typename TIntegral , typename TIntegralSquared , unsigned int tChannels>
void Ocean::CV::IntegralImage::createLinedImageAndSquared ( const T *  source,
TIntegral *  integral,
TIntegralSquared *  integralSquared,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements,
const unsigned int  integralSquaredPaddingElements 
)
static

Creates an integral image and squared integral image from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border.

The result are two individual integral images, one for the pixel intensities and one for the squared pixel intensities.
The resulting lined integral images have the following scheme:

Integral image:                     Integral squared image:
 ---------------- ---------          ------------------------ ---------
|0000000000000000|         |        |000000000000000000000000|         |
|00|-------------|         |        |00|---------------------|         |
|00|             | padding |        |00|                     | padding |
|00| I0 I1 I0 I1 |         |        |00| I0^2 I1^2 I0^2 I1^2 |         |
|00|             |         |        |00|                     |         |
 ---------------- ---------          ------------------------ ---------
With I0 integral value of the first channel,
I1 integral value of the second channel,
I0^2 integral squared value of the first channel,
I1^2 integral squared value of the second channel.

The resolution of the integral image are: (width + 1)x(height + 1).

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (width + 1)x(height + 1), must be valid
integralSquaredThe resulting squared integral image, with size (width + 1)x(height + 1), must be valid
widthThe width of the source frame in pixel, with range [1, infinity)
heightThe height of the source frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
integralSquaredPaddingElementsThe number of padding elements at the end of each row of the integral squared frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
TIntegralSquaredThe data type of each squared integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createLinedImage(), createLinedImageSquared().

◆ createLinedImageAndSquared() [2/2]

template<typename T , typename TIntegralAndSquared , unsigned int tChannels>
void Ocean::CV::IntegralImage::createLinedImageAndSquared ( const T *  source,
TIntegralAndSquared *  integralAndSquared,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  integralAndSquaredPaddingElements 
)
static

Creates an integral image and squared integral image from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border.

The resulting integral image provides access to pixel intensities and squared pixel intensities.
Beware: As the same data type is used for both integral data, the depth of the data type must be large enough, or the image resolution must be small enough to avoid overflows.
Pixel intensities and squared pixel intensities are interleaved so that both values can be looked-up at the same memory location.
In case, the given frame has more than one channel, the channels of the resulting integral image will be interleaved (not stored as individual planes).
The resulting lined integral image has the following scheme:

 ------------------------------------ ---------
|000000000000000000000000000000000000|         |
|00|---------------------------------|         |
|00|                                 | padding |
|00| I0 I1 I0^2 I1^2 I0 I1 I0^2 I1^2 |         |
|00|                                 |         |
 ------------------------------------ ---------
With I0 integral value of the first channel,
I1 integral value of the second channel,
I0^2 integral squared value of the first channel,
I1^2 integral squared value of the second channel.

The resolution of the integral image is: ((width + 1) * 2)x(height + 1).

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralAndSquaredThe resulting integral (and squared integral) image, with size ((width + 1) * 2)x(height + 1), must be valid
widthThe width of the source frame in pixel, with range [1, infinity)
heightThe height of the source frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralAndSquaredPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralAndSquaredThe data type of each integral (and squared integral) pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createLinedImage(), createLinedImageSquared().

◆ createLinedImageSquared()

template<typename T , typename TIntegral , unsigned int tChannels>
void Ocean::CV::IntegralImage::createLinedImageSquared ( const T *  source,
TIntegral *  integral,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  integralPaddingElements 
)
static

Creates an integral image with squared pixel intensities from a given 1-plane image and adds an extra line (one column and one row) with zeros to the left and top image border.

In case, the given frame has more than one channel, the channels of the resulting integral image will be interleaved (not stored as individual planes).
The resulting lined integral image has the following scheme:

 -------------- ---------
|00000000000000|         |
|0|------------|         |
|0|            | padding |
|0| Integral^2 |         |
|0|            |         |
 -------------- ---------

The resolution of the integral image is: (width + 1)x(height + 1).

Parameters
sourceThe image for which the integral image will be determined, with size width x height, must be valid
integralThe resulting integral image, with size (width + 1)x(height + 1), must be valid
widthThe width of the source frame in pixel, with range [0, infinity)
heightThe height of the source frame in pixel, with range [0, infinity)
sourcePaddingElementsThe number of padding elements at the end of each row of the source frame, in elements, with range [0, infinity)
integralPaddingElementsThe number of padding elements at the end of each row of the integral frame, in elements, with range [0, infinity)
Template Parameters
TThe data type of each pixel element of the source frame e.g., 'uint8_t' or 'float'
TIntegralThe data type of each integral pixel element, e.g., 'unsigned int' or 'double'
tChannelsThe number of channels the source frame has, with range [1, infinity)
See also
createLinedImageAndSquared(), createImage(), createBorderedImage().

◆ linedIntegralSum() [1/2]

template<typename TIntegral >
static OCEAN_FORCE_INLINE TIntegral Ocean::CV::IntegralImage::linedIntegralSum ( const TIntegral *const  linedIntegral,
const unsigned int  linedIntegralStrideElements,
const unsigned int  windowLeft,
const unsigned int  windowTop,
const unsigned int  windowWidth,
const unsigned int  windowHeight 
)
static

Determines the sum of elements within a window from an integral image.

The lined integral image must have the following scheme:

   integralStrideElements
|<------------------------>|

 ---------------- ---------
|0000000000000000|         |
|0|--------------|         |
|0|              | padding |
|0|   Integral   |         |
|0|              |         |
 ----------------- ---------

  |<------------>|
   original width

|<-------------->|
lined integral width
Parameters
linedIntegralThe lined integral image, must be valid
linedIntegralStrideElementsThe number of elements between two row start positions in the lined integral image, in elements, may contain padding elements at the end of each row, with range [originalImageWidth + 1, infinity)
windowLeftThe left starting point of the window, in pixel, with range [0, originalImageWidth - 1]
windowTopThe top starting point of the window, in pixel, with range [0, originalImageHeight - 1]
windowWidthThe width of the window, in pixel, with range [1, originalImageWidth - windowLeft]
windowHeightThe height of the window, in pixel, with range [1, originalImageHeight - windowTop]
Returns
The resulting sum of elements
Template Parameters
TIntegralThe data type of the elements in the integral image

◆ linedIntegralSum() [2/2]

template<typename TIntegral >
TIntegral Ocean::CV::IntegralImage::linedIntegralSum ( const TIntegral *const  linedIntegral,
const unsigned int  linedIntegralStrideElements,
const unsigned int  windowLeft,
const unsigned int  windowTop,
const unsigned int  windowWidth,
const unsigned int  windowHeight 
)
inline

◆ linedIntegralVariance() [1/3]

template<typename TIntegral , typename TIntegralSquared , typename TVariance , bool tReturnMean>
TVariance Ocean::CV::IntegralImage::linedIntegralVariance ( const TIntegral *  linedIntegral,
const TIntegralSquared *  linedIntegralSquared,
const unsigned int  integralStrideElements,
const unsigned int  integralStrideSquaredElements,
const unsigned int  windowALeft,
const unsigned int  windowATop,
const unsigned int  windowAWidth,
const unsigned int  windowAHeight,
const unsigned int  windowBLeft,
const unsigned int  windowBTop,
const unsigned int  windowBWidth,
const unsigned int  windowBHeight,
const unsigned int  windowCLeft,
const unsigned int  windowCTop,
const unsigned int  windowCWidth,
const unsigned int  windowCHeight,
TVariance *  mean = nullptr 
)
inlinestatic

Determines the variance of elements within three windows from two integral images.

The three windows are treated as one joined area.

Parameters
linedIntegralThe lined integral image, must be valid
linedIntegralSquaredThe lined integral image with squared values, must be valid
integralStrideElementsThe number of elements between two row starts in the lined integral image, in elements, may contain padding elements at the end of each row, with range [2, infinity)
integralStrideSquaredElementsThe number of elements between two row starts in the lined integral squared image, in elements, may contain padding elements at the end of each row, with range [2, infinity)
windowALeftThe left starting point of the first window, in pixel, with range [0, originalImageWidth - 1]
windowATopThe top starting point of the first window, in pixel, with range [0, originalImageHeight - 1]
windowAWidthThe width of the first window, in pixel, with range [1, originalImageWidth - windowALeft]
windowAHeightThe height of the first window, in pixel, with range [1, originalImageHeight - windowATop]
windowBLeftThe left starting point of the second window, in pixel, with range [0, originalImageWidth - 1]
windowBTopThe top starting point of the second window, in pixel, with range [0, originalImageHeight - 1]
windowBWidthThe width of the second window, in pixel, with range [1, originalImageWidth - windowBLeft]
windowBHeightThe height of the second window, in pixel, with range [1, originalImageHeight - windowBTop]
windowCLeftThe left starting point of the third window, in pixel, with range [0, originalImageWidth - 1]
windowCTopThe top starting point of the third window, in pixel, with range [0, originalImageHeight - 1]
windowCWidthThe width of the third window, in pixel, with range [1, originalImageWidth - windowCLeft]
windowCHeightThe height of the third window, in pixel, with range [1, originalImageHeight - windowCTop]
meanOptional resulting mean value and (tReturnMean = true), nullptr otherwise (and tReturnMean = false)
Returns
The resulting variance, with range [0, infinity)
Template Parameters
TIntegralThe data type of the elements in the integral image
TIntegralSquaredThe data type of the elements in the integral squared image
TVarianceThe data type of the resulting variance (also used for intermediate calculations)
tReturnMeanTrue, to return the mean value (mean must be defined); False, to skip calculating of mean (mean must be nullptr)

◆ linedIntegralVariance() [2/3]

template<typename TIntegral , typename TIntegralSquared , typename TVariance , bool tReturnMean>
TVariance Ocean::CV::IntegralImage::linedIntegralVariance ( const TIntegral *  linedIntegral,
const TIntegralSquared *  linedIntegralSquared,
const unsigned int  integralStrideElements,
const unsigned int  integralStrideSquaredElements,
const unsigned int  windowALeft,
const unsigned int  windowATop,
const unsigned int  windowAWidth,
const unsigned int  windowAHeight,
const unsigned int  windowBLeft,
const unsigned int  windowBTop,
const unsigned int  windowBWidth,
const unsigned int  windowBHeight,
TVariance *  mean = nullptr 
)
inlinestatic

Determines the variance of elements within two windows from two integral images.

The two windows are treated as one joined area.
Variance is calculated based on the following equation:

Var(x) = E[(x - E[x])^2] = E[x^2] - E[x]^2

The variance is determined based on the standard lined integral image and the lined integral image for squared values.
The lined integral image must have the following scheme:

   integralStrideElements                      integralSquaredStrideElements
|<------------------------>|                   |<------------------------------>|

 ---------------- ---------                 -------------------- -----------
|0000000000000000|         |                   |00000000000000000000|           |
|0|--------------|         |                   |0|------------------|           |
|0|              | padding |                   |0|                  |  padding  |
|0|   Integral   |         |                   |0|    Integral^2    |           |
|0|              |         |                   |0|                  |           |
 ----------------- ---------                    -------------------- -----------

  |<------------>|                           |<---------------->|
   original width                                original width

|<-------------->|                         |<------------------>|
lined integral width                         lined integral squared width
Parameters
linedIntegralThe lined integral image, must be valid
linedIntegralSquaredThe lined integral image with squared values, must be valid
integralStrideElementsThe number of elements between two row starts in the lined integral image, in elements, may contain padding elements at the end of each row, with range [2, infinity)
integralStrideSquaredElementsThe number of elements between two row starts in the lined integral squared image, in elements, may contain padding elements at the end of each row, with range [2, infinity)
windowALeftThe left starting point of the first window, in pixel, with range [0, originalImageWidth - 1]
windowATopThe top starting point of the first window, in pixel, with range [0, originalImageHeight - 1]
windowAWidthThe width of the first window, in pixel, with range [1, originalImageWidth - windowALeft]
windowAHeightThe height of the first window, in pixel, with range [1, originalImageHeight - windowATop]
windowBLeftThe left starting point of the second window, in pixel, with range [0, originalImageWidth - 1]
windowBTopThe top starting point of the second window, in pixel, with range [0, originalImageHeight - 1]
windowBWidthThe width of the second window, in pixel, with range [1, originalImageWidth - windowBLeft]
windowBHeightThe height of the second window, in pixel, with range [1, originalImageHeight - windowBTop]
meanOptional resulting mean value and (tReturnMean = true), nullptr otherwise (and tReturnMean = false)
Returns
The resulting variance, with range [0, infinity)
Template Parameters
TIntegralThe data type of the elements in the integral image
TIntegralSquaredThe data type of the elements in the integral squared image
TVarianceThe data type of the resulting variance (also used for intermediate calculations)
tReturnMeanTrue, to return the mean value (mean must be defined); False, to skip calculating of mean (mean must be nullptr)

◆ linedIntegralVariance() [3/3]

template<typename TIntegral , typename TIntegralSquared , typename TVariance , bool tReturnMean>
TVariance Ocean::CV::IntegralImage::linedIntegralVariance ( const TIntegral *  linedIntegral,
const TIntegralSquared *  linedIntegralSquared,
const unsigned int  integralStrideElements,
const unsigned int  integralStrideSquaredElements,
const unsigned int  windowLeft,
const unsigned int  windowTop,
const unsigned int  windowWidth,
const unsigned int  windowHeight,
TVariance *  mean = nullptr 
)
inlinestatic

Determines the variance of elements within a window from two integral images.

Variance is calculated based on the following equation:

Var(x) = E[(x - E[x])^2] = E[x^2] - E[x]^2

The variance is determined based on the standard lined integral image and the lined integral image for squared values.
The lined integral image must have the following scheme:

   integralStrideElements                      integralSquaredStrideElements
|<------------------------>|                   |<------------------------------>|

 ---------------- ---------                 -------------------- -----------
|0000000000000000|         |                   |00000000000000000000|           |
|0|--------------|         |                   |0|------------------|           |
|0|              | padding |                   |0|                  |  padding  |
|0|   Integral   |         |                   |0|    Integral^2    |           |
|0|              |         |                   |0|                  |           |
 ----------------- ---------                    -------------------- -----------

  |<------------>|                           |<---------------->|
   original width                                original width

|<-------------->|                         |<------------------>|
lined integral width                         lined integral squared width
Parameters
linedIntegralThe lined integral image, must be valid
linedIntegralSquaredThe lined integral image with squared values, must be valid
integralStrideElementsThe number of elements between two row starts in the lined integral image, in elements, may contain padding elements at the end of each row, with range [2, infinity)
integralStrideSquaredElementsThe number of elements between two row starts in the lined integral squared image, in elements, may contain padding elements at the end of each row, with range [2, infinity)
windowLeftThe left starting point of the window, in pixel, with range [0, originalImageWidth - 1]
windowTopThe top starting point of the window, in pixel, with range [0, originalImageHeight - 1]
windowWidthThe width of the window, in pixel, with range [1, originalImageWidth - windowLeft]
windowHeightThe height of the window, in pixel, with range [1, originalImageHeight - windowTop]
meanOptional resulting mean value and (tReturnMean = true), nullptr otherwise (and tReturnMean = false)
Returns
The resulting variance, with range [0, infinity)
Template Parameters
TIntegralThe data type of the elements in the integral image
TIntegralSquaredThe data type of the elements in the integral squared image
TVarianceThe data type of the resulting variance (also used for intermediate calculations)
tReturnMeanTrue, to return the mean value (mean must be defined); False, to skip calculating of mean (mean must be nullptr)

◆ sqr()

template<typename T , typename TSquared >
TSquared Ocean::CV::IntegralImage::sqr ( const T &  value)
inlinestaticprivate

Returns the square value of the given parameter.

Parameters
valueThe value to be squared
Returns
Square value
Template Parameters
TThe data type of the value to be squared
TSquaredThe data type of the squared value

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