Unlock this feature

This feature isn’t part of your plan yet

Contact sales to get upgraded to the full DevStudio experience.

Unlock this feature

This feature isn't part of your plan yet.

Color Space Conversions

RGB/BGR --> HSV

colorConvertfunction
File: /src/image.hppLines 3772–3803

Converts 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)
NameTypeDefaultDescription
convertMethodColorConversionMethodOptions are ColorConversionMethod::BGR_TO_HSV or ColorConversionMethod::RGB_TO_HSV. / // clang-format on
DdrInOutShapetypenameThe in/out image shape
OcmAllocatorTypetypenameType of OCM memory allocator
NameTypeDescription
InputImageDdrInOutShape&The input image tensor. Input is in (r,g,b) or (b,g,r) format.
OutputImageDdrInOutShape&The output image tensor. Output is in (h, s, v) format (0 < hue < 180 as in CV2).
ocmMemAllocOcmAllocatorType&OCM memory allocator

INLINE void

Grayscale

grayscalefunction
File: /src/image.hppLines 3500–3523

Grayscale 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)
NameTypeDefaultDescription
OcmInputImageShapetypenameTensor with `uint8` type and shape `(1, 3, height, width)`.
OcmOutputImageShapetypenameTensor with `uint8` type and shape `(1, 1, height, width)`.
NameTypeDescription
ocmInputOcmInputImageShape&Input tensor.
ocmOutOcmOutputImageShape&Output tensor.
fxChannel1WeightFixedPoint16<12>Grayscale weight for first chanel (defaults assume BGR order).
fxChannel2WeightFixedPoint16<12>Grayscale weight for second chanel (defaults assume BGR order).
fxChannel3WeightFixedPoint16<12>Grayscale weight for third chanel (defaults assume BGR order).

void

grayscalefunction
File: /src/image.hppLines 3541–3614

Grayscale 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)
NameTypeDefaultDescription
OcmInputImageShapetypenameTensor with `uint8` type and shape `(1, 1, height, 3 * width)`.
OcmOutputImageShapetypenameTensor with `uint8` type and shape `(1, 1, height, width)`.
NameTypeDescription
ocmInputImageOcmInputImageShape&Input tensor.
ocmOutputImageOcmOutputImageShape&Output tensor.
fxChannel1WeightFixedPoint16<12>Grayscale weight for first chanel (defaults assume BGR order).
fxChannel2WeightFixedPoint16<12>Grayscale weight for second chanel (defaults assume BGR order).
fxChannel3WeightFixedPoint16<12>Grayscale weight for third chanel (defaults assume BGR order). / // clang-format on

void

Sign in to your account

Don't have an account? 
By signing in, you are agreeing to our Terms of Use and Privacy Policy.
Quadric // One architecture. Every algorithm.

Develop.

Simulate.

Profile.

Collaborate.