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

File: src/image.hppLines 3682–3713
    /**
     * @brief 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.
     * @tparam convertMethod depending upon conversion HSV TO RGB , Or BGR TO HSV
     * @tparam DdrInOutShape The in/out image shape
     * @tparam OcmAllocatorType Type of OCM memory allocator
     * @param InputImage The input image tensor. Input is in (r,g,b) or (b,g,r) format.
     * @param OutputImage The output image tensor. Output is in (h, s, v) format (0 < hue < 180 as in CV2).
     * @param ocmMemAlloc OCM memory allocator
     * @param convertMethod Options are ColorConversionMethod::BGR_TO_HSV or ColorConversionMethod::RGB_TO_HSV.
     */
    // clang-format on
    template <ColorConversionMethod convertMethod, typename DdrInOutShape, typename OcmAllocatorType>
    INLINE void colorConvert(DdrInOutShape& InputImage, DdrInOutShape& OutputImage, OcmAllocatorType& ocmMemAlloc) {

Grayscale

File: /src/image.hppLines 3432–3451
    /**
     * @brief Grayscale color conversion that accepts input in planar format, i.e. `(1, 1, height, width)`.
     *
     * @tparam OcmInputImageShape Tensor with `uint8` type and shape `(1, 3, height, width)`.
     * @tparam OcmOutputImageShape Tensor with `uint8` type and shape `(1, 1, height, width)`.
     * @param ocmInput Input tensor.
     * @param ocmOut Output tensor.
     * @param fxChannel1Weight Grayscale weight for first chanel (defaults assume BGR order).
     * @param fxChannel2Weight Grayscale weight for second chanel (defaults assume BGR order).
     * @param fxChannel3Weight Grayscale weight for third chanel (defaults assume BGR order).
     */
    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) {
File: /src/image.hppLines 3469–3491
    /**
     * @brief Grayscale color conversion that accepts input in interleaved format, i.e. `(1, 1, height, 3 * width)`.
     *
     * Channels are packed in width.
     *
     * @tparam OcmInputImageShape Tensor with `uint8` type and shape `(1, 1, height, 3 * width)`.
     * @tparam OcmOutputImageShape Tensor with `uint8` type and shape `(1, 1, height, width)`.
     * @param ocmInputImage Input tensor.
     * @param ocmOutputImage Output tensor.
     * @param fxChannel1Weight Grayscale weight for first chanel (defaults assume BGR order).
     * @param fxChannel2Weight Grayscale weight for second chanel (defaults assume BGR order).
     * @param fxChannel3Weight Grayscale weight for third chanel (defaults assume BGR order).
     */
    // clang-format on
    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) {

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.