RGB/BGR --> HSV
colorConvertfunction
File:
/src/image.hppLines 3772–3803Converts a RGB/BGR input image to HSV in place.
Assuming an RGB input image would look like in NCHW format:
┌----------------------------...-┐ ┌----------------------------...-┐
|B, B, B, B, B, B, ... channel 2 | |V, V, V, V, V, V, ... channel 2 |
| ┌---------------------------...-┐ | ┌---------------------------...-┐
| |G, G, G, G, G, G, ...channel 1 | | |S, S, S, S, S, S, ...channel 1 |
| | ┌---------------------------...-┐ | | ┌---------------------------...-┐
| | |R, R, R, R, R, R, ...channel 0 | => | | |H, H, H, H, H, H, ...channel 0 |
| | |R, R, R, R, R, R, ... | | | |H, H, H, H, H, H, ... |
└ | |---------------------------...-| └ | |---------------------------...-|
| |. | | |. |
└ |. | └ |. |
|. | |. |
└---------------------------...-┘ └---------------------------...-┘
The ouput is HSV channels for the input image. 8bit color depth is assumed.
template <ColorConversionMethod convertMethod,
typename DdrInOutShape,
typename OcmAllocatorType>
INLINE void colorConvert(DdrInOutShape& InputImage,
DdrInOutShape& OutputImage,
OcmAllocatorType& ocmMemAlloc)Template Parameters
| Name | Type | Default | Description |
|---|---|---|---|
convertMethod | ColorConversionMethod | Options are ColorConversionMethod::BGR_TO_HSV or ColorConversionMethod::RGB_TO_HSV. / // clang-format on | |
DdrInOutShape | typename | The in/out image shape | |
OcmAllocatorType | typename | Type of OCM memory allocator |
Parameters
| Name | Type | Description |
|---|---|---|
InputImage | DdrInOutShape& | The input image tensor. Input is in (r,g,b) or (b,g,r) format. |
OutputImage | DdrInOutShape& | The output image tensor. Output is in (h, s, v) format (0 < hue < 180 as in CV2). |
ocmMemAlloc | OcmAllocatorType& | OCM memory allocator |
Returns
INLINE void
Grayscale
grayscalefunction
File:
/src/image.hppLines 3500–3523Grayscale color conversion that accepts input in planar format, i.e. (1, 1, height, width).
template <typename OcmInputImageShape,
typename OcmOutputImageShape,
typename std::enable_if_t<OcmInputImageShape::NUM_COLS == OcmOutputImageShape::NUM_COLS, std::int32_t> = 0>
void grayscale(OcmInputImageShape& ocmInput,
OcmOutputImageShape& ocmOut,
FixedPoint16<12> fxChannel1Weight = 0.114,
FixedPoint16<12> fxChannel2Weight = 0.587,
FixedPoint16<12> fxChannel3Weight = 0.299)Template Parameters
| Name | Type | Default | Description |
|---|---|---|---|
OcmInputImageShape | typename | Tensor with `uint8` type and shape `(1, 3, height, width)`. | |
OcmOutputImageShape | typename | Tensor with `uint8` type and shape `(1, 1, height, width)`. |
Parameters
| Name | Type | Description |
|---|---|---|
ocmInput | OcmInputImageShape& | Input tensor. |
ocmOut | OcmOutputImageShape& | Output tensor. |
fxChannel1Weight | FixedPoint16<12> | Grayscale weight for first chanel (defaults assume BGR order). |
fxChannel2Weight | FixedPoint16<12> | Grayscale weight for second chanel (defaults assume BGR order). |
fxChannel3Weight | FixedPoint16<12> | Grayscale weight for third chanel (defaults assume BGR order). |
Returns
void
grayscalefunction
File:
/src/image.hppLines 3541–3614Grayscale color conversion that accepts input in interleaved format, i.e. (1, 1, height, 3 * width).
Channels are packed in width.
template <typename OcmInputImageShape,
typename OcmOutputImageShape,
typename std::enable_if_t<OcmInputImageShape::NUM_COLS == OcmOutputImageShape::NUM_COLS * 3, std::int32_t> = 0>
void grayscale(OcmInputImageShape& ocmInputImage,
OcmOutputImageShape& ocmOutputImage,
FixedPoint16<12> fxChannel1Weight = 0.114,
FixedPoint16<12> fxChannel2Weight = 0.587,
FixedPoint16<12> fxChannel3Weight = 0.299)Template Parameters
| Name | Type | Default | Description |
|---|---|---|---|
OcmInputImageShape | typename | Tensor with `uint8` type and shape `(1, 1, height, 3 * width)`. | |
OcmOutputImageShape | typename | Tensor with `uint8` type and shape `(1, 1, height, width)`. |
Parameters
| Name | Type | Description |
|---|---|---|
ocmInputImage | OcmInputImageShape& | Input tensor. |
ocmOutputImage | OcmOutputImageShape& | Output tensor. |
fxChannel1Weight | FixedPoint16<12> | Grayscale weight for first chanel (defaults assume BGR order). |
fxChannel2Weight | FixedPoint16<12> | Grayscale weight for second chanel (defaults assume BGR order). |
fxChannel3Weight | FixedPoint16<12> | Grayscale weight for third chanel (defaults assume BGR order). / // clang-format on |
Returns
void
