Image Processing Functions

blurImage

template<std::uint32_t filterSize = 1>
qVar_t<FixedPoint32<16>> qmath::blurImage(qVar_t<FixedPoint32<16>> qFrame)

Applies a 3x3 blur function on a qVar. The filter is.

* ┌           ┐
* │   1 2 1   │
* │   2 4 2   │  / 16
* │   1 2 1   │
* └           ┘
*
Return

qVar_t<FixedPoint32<16>> The blurred output of the tile

Parameters
  • qFrame: The input Frame tile

sobelImage

template<std::uint32_t filterSize = 1>
qVar_t<FixedPoint32<16>> qmath::sobelImage(qVar_t<FixedPoint32<16>> qFrame)

Applies a 3x3 sobel vertical edge detection. The filter is Vertical edge filter.

* ┌            ┐
* │  -1 -2 -1  │
* │   0  0  0  │  / 4
* │   1  2  1  │
* └            ┘
*
Horizontal edge filter
* ┌          ┐
* │  -1 0 1  │
* │  -2 0 2  │  / 4
* │  -1 0 1  │
* └          ┘
*
Return

qVar_t<FixedPoint32<16>> The vertical edges in the tile

Parameters
  • qFrame: The input Frame tile

edgeImage3x3

qVar_t<FixedPoint32<16>> qmath::edgeImage3x3(qVar_t<FixedPoint32<16>> qFrame)

Gets an image of all the adges in a tile calculated using the sobel filter.

Return

qVar_t<FixedPoint32<16>> The edge image tile

Parameters
  • qFrame: The input image tile

imageResize

template<typename OcmInputImageShape, typename OcmOutputImageShape>
void qmath::imageResize(OcmInputImageShape &ocmInputImage, OcmOutputImageShape &ocmOutputImage)

Reduces the size of a 3 channel image.

Assuming a BGR input image would look like

* ┌--------------------------------...-┐
* |BGR,BGR,|BGR,BGR,|BGR,BGR, ...      |
* |BGR,BGR,|BGR,BGR,|BGR,BGR, ...      |
* |--------------------------------...-|
* |BGR,BGR,|BGR,BGR,|BGR,BGR, ...      |
* |.                                   |
* |.                                   |
* |.                                   |
* └--------------------------------...-┘
*
The output is calculated as the average channel value in each of the 2x2 squares. A row of output is processed at a time, i.e. two rows of input is brought in. If the row is too large it is broken up into chunks based on maxOutTilesInBuffer(32)

Template Parameters
  • OcmInputImageShape: The shape of the input image with 3 channels

  • OcmOutputImageShape: The shape of the output image with 3 channels

Parameters
  • ocmInputImage: The input image tensor

  • ocmOutputImage: The output image tensor

imageGrayscale

template<typename OcmInputImageShape, typename OcmOutputImageShape>
void qmath::imageGrayscale(OcmInputImageShape &ocmInputImage, OcmOutputImageShape &ocmOutputImage, FixedPoint16<12> fxChannel1Weight = 0.114, FixedPoint16<12> fxChannel2Weight = 0.587, FixedPoint16<12> fxChannel3Weight = 0.299)

Converts a 3 channel image to grayscale, default values work best for a BGR input image.

Assuming a BGR input image would look like

* ┌------------------------------...-┐
* |BGR,BGR,BGR,BGR,BGR,BGR, ...      |
* |BGR,BGR,BGR,BGR,BGR,BGR, ...      |
* |------------------------------...-|
* |BGR,BGR,BGR,BGR,BGR,BGR, ...      |
* |.                                 |
* |.                                 |
* |.                                 |
* └------------------------------...-┘
*

The ouput is a weighted sum of the 3 channels for each pixel. Enough rows of the image are processed to fill out maxOutTilesInBuffer(128) unless one row does not fit into the buffer. In that case each row is broken up into multiple buffers to fill out maxOutTilesInBuffer

Template Parameters
  • OcmInputImageShape: The input image shape in (b,g,r) format

  • OcmOutputImageShape: The output image shape in (b,g,r) format

Parameters
  • ocmInputImage: The input image tensor

  • ocmOutputImage: The output image tensor

  • fxBlueWeight: The weight given to the blue channel. Default 0.114

  • fxGreenWeight: The weight given to the green channel. Default 0.587

  • fxRedWeight: The weight given to the red channel. Default 0.299