Ocean
Ocean::CV::FrameConverterThreshold Class Reference

This class implements frame converters dividing a frame by application of a threshold. More...

Inheritance diagram for Ocean::CV::FrameConverterThreshold:

Static Public Member Functions

static void convertY8ToB8 (uint8_t *buffer, const unsigned int width, const unsigned int height, const unsigned int bufferPaddingElements, const uint8_t threshold, Worker *worker=nullptr)
 Converts an 8 bit (grayscale) frame into a binary frame using a threshold value. More...
 
static void convertY8ToB8 (const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const uint8_t threshold, Worker *worker=nullptr)
 Converts an 8 bit gray scale frame into a second binary frame using a threshold. More...
 
static void convertBorderedY8ToB8 (const uint8_t *source, const uint32_t *sourceBorderedIntegral, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int sourceBorderedIntegralPaddingElements, const unsigned int targetPaddingElements, const unsigned int kernelSize, const float threshold, Worker *worker=nullptr)
 Converts a gray scale frame into a second binary frame using a relative threshold and a kernel size. More...
 
static uint8_t calculateOtsuThreshold (const uint8_t *source, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, Worker *worker=nullptr)
 Calculate binarization threshold for a given image by application of the Otsu algorithm. More...
 
- Static Public Member Functions inherited from Ocean::CV::FrameConverter
template<typename TSource , typename TTarget >
static void cast (const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
 Casts the pixel values from one frame type to another frame type. More...
 
template<typename TSource , typename TTarget >
static void normalizedCast (const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const TTarget multiplicationFactor, const TTarget offset, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
 Casts the pixel values from one frame type to another frame type but also normalizes the casted source values before assigning them (by scaling and offsetting). More...
 
template<typename T >
static bool subFrame (const T *source, T *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
 Copies a sub-frame of a given frame into a second frame while both frames might have an individual number of padding elements at the end of each row. More...
 
template<typename T >
static bool subFrameMask (const Frame &sourceFrame, Frame &targetFrame, const Frame &maskFrame, const uint32_t sourceLeft, const uint32_t sourceTop, const uint32_t targetLeft, const uint32_t targetTop, const uint32_t subFrameWidth, const uint32_t subFrameHeight, const uint8_t maskValue=0u)
 Copies pixels from one sub-frame to another if the pixels are part of a mask; input may use padding. More...
 
template<typename T >
static bool subFrameMask (const T *source, T *target, const uint8_t *mask, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int maskPaddingElements, const uint8_t maskValue=0u)
 Copies pixels from one sub-frame to another if the pixels are part of a mask; input may use padding. More...
 
template<typename T >
static void patchFrame (const T *source, T *buffer, const unsigned int width, const unsigned int channels, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
 Copies a small patch area of a given frame into a buffer holding only the entire patch. More...
 
template<typename T , unsigned int tChannels>
static void patchFrameMirroredBorder (const T *source, T *buffer, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int patchSize, const unsigned int sourcePaddingElements, const unsigned int bufferPaddingElements)
 Copies a small patch area of a frame into a buffer holding only the entire patch. More...
 
static MatrixD transformationMatrix_FullRangeRGB24_To_FullRangeYUV24_BT601 ()
 Returns the 3x4 color space transformation matrix from full range RGB24 to full range YUV24 using BT.601, analog RGB to (analog) YPbPr. More...
 
static MatrixD transformationMatrix_FullRangeRGB24_To_FullRangeYVU24_BT601 ()
 Returns the 3x4 color space transformation matrix from full range RGB24 to full range YVU24 using BT.601, analog RGB to (analog) YPbPr. More...
 
static MatrixD transformationMatrix_FullRangeRGB24_To_LimitedRangeYUV24_BT601 ()
 Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YUV24 using BT.601, analog RGB to (digital) YCbCr. More...
 
static MatrixD transformationMatrix_FullRangeRGB24_To_LimitedRangeYVU24_BT601 ()
 Returns the 3x4 color space transformation matrix from full range RGB24 to limited range YVU24 using BT.601, analog RGB to (digital) YCbCr. More...
 
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_BT601 ()
 Returns the color space transformation matrix from full range YUV24 to full range BGR24 using BT.601, (analog) YPbPr to analog BGR. More...
 
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_BT601 ()
 Returns the color space transformation matrix from full range YUV24 to full range RGB24 using BT.601, (analog) YPbPr to analog RGB. More...
 
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeBGR24_Android ()
 Returns the color space transformation matrix from full range YUV24 to full range BGR24 similar to BT.601, (analog) YPbPr to analog BGR. More...
 
static MatrixD transformationMatrix_FullRangeYUV24_To_FullRangeRGB24_Android ()
 Returns the color space transformation matrix from full range YUV24 to full range RGB24 similar to BT.601, (analog) YPbPr to analog RGB. More...
 
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeBGR24_Android ()
 Returns the color space transformation matrix from full range YVU24 to full range BGR24 similar to BT.601, (analog) YPbPr to analog BGR. More...
 
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_Android ()
 Returns the color space transformation matrix from full range YVU24 to full range RGB24 similar to BT.601, (analog) YPbPr to analog RGB. More...
 
static MatrixD transformationMatrix_LimitedRangeYUV24_To_FullRangeRGB24_BT601 ()
 Returns the color space transformation matrix from limited range YUV24 to full range RGB24 using BT.601, (digital) YCbCr to analog RGB. More...
 
static MatrixD transformationMatrix_FullRangeBGR24_To_LimitedRangeYUV24_BT601 ()
 Returns the color space transformation matrix from full range BGR24 to limited range YUV24 using BT.601, analog RGB to (digital) YCbCr. More...
 
static MatrixD transformationMatrix_FullRangeBGR24_To_FullRangeYUV24_BT601 ()
 Returns the 3x4 color space transformation matrix from full range BGR24 to full range YUV24 using BT.601, analog BGR to (analog) YPbPr. More...
 
static MatrixD transformationMatrix_FullRangeBGR24_To_FullRangeYVU24_BT601 ()
 Returns the 3x4 color space transformation matrix from full range BGR24 to full range YVU24 using BT.601, analog BGR to (analog) YPbPr. More...
 
static MatrixD transformationMatrix_LimitedRangeYUV24_To_FullRangeBGR24_BT601 ()
 Returns the color space transformation matrix from limited range YUV24 to full range BGR24 using BT.601, (digital) YCbCr to analog BGR. More...
 
static MatrixD transformationMatrix_LimitedRangeYVU24_To_FullRangeBGR24_BT601 ()
 Returns the color space transformation matrix from limited range YVU24 to full range BGR24 using BT.601, (digital) YCrCb to analog BGR. More...
 
static MatrixD transformationMatrix_LimitedRangeYVU24_To_FullRangeRGB24_BT601 ()
 Returns the color space transformation matrix from limited range YVU24 to full range RGB24 using BT.601, (digital) YCrCb to analog RGB. More...
 
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeRGB24_BT601 ()
 Returns the color space transformation matrix from full range YVU24 to full range RGB24 using BT.601, (digital) YCrCb to analog RGB. More...
 
static MatrixD transformationMatrix_FullRangeYVU24_To_FullRangeBGR24_BT601 ()
 Returns the color space transformation matrix from full range YVU24 to full range BGR24 using BT.601, (digital) YCrCb to analog BGR. More...
 
static const ConversionFlagsconversionFlags ()
 Returns a vector holding all possible conversion flags. More...
 
static std::string translateConversionFlag (const ConversionFlag conversionFlag)
 Translates a given conversion flag to a string. More...
 

Static Protected Member Functions

static void convertY8ToB8Subset (uint8_t *buffer, const unsigned int width, const unsigned int height, const unsigned int bufferPaddingElements, const uint8_t threshold, const unsigned int firstRow, const unsigned int numberRows)
 Converts an 8 bit gray scale frame into a binary frame using a threshold. More...
 
static void convertY8ToB8Subset (const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const uint8_t threshold, const unsigned int firstRow, const unsigned int numberRows)
 Converts an 8 bit gray scale frame into a second binary frame using a threshold. More...
 
static void convertBorderedY8ToB8Subset (const uint8_t *source, const uint32_t *sourceBorderedIntegral, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int sourceBorderedIntegralPaddingElements, const unsigned int targetPaddingElements, const unsigned int kernelSize, const float threshold, const unsigned int firstRow, const unsigned int numberRows)
 Converts a gray scale frame into a second binary frame using a relative threshold and a kernel size. More...
 
- Static Protected Member Functions inherited from Ocean::CV::FrameConverter
template<typename TSource , typename TTarget >
static void cast16Elements (const TSource *const source, TTarget *const target)
 Casts 16 successive elements from one data type to another data type. More...
 
template<typename TSource , typename TTarget >
static void convertGenericPixelFormat (const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideElements, const unsigned int targetStrideElements, const ConversionFlag flag, const RowConversionFunction< TSource, TTarget > rowConversionFunction, const RowReversePixelOrderInPlaceFunction< TTarget > targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void *options, Worker *worker)
 Converts a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic pixel format (e.g., RGB24, Y8). More...
 
static void convertArbitraryPixelFormat (const void **sources, void **targets, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int multipleRowsPerIteration, const MultipleRowsConversionFunction multipleRowsConversionFunction, const void *options, Worker *worker)
 Converts a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbitrary pixel format. More...
 
static void convertGenericPixelFormatSubset (const uint8_t *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourceStrideBytes, const unsigned int targetStrideBytes, const ConversionFlag flag, const RowConversionFunction< uint8_t, uint8_t > rowConversionFunction, const RowReversePixelOrderInPlaceFunction< uint8_t > targetReversePixelOrderInPlaceFunction, const bool areContinuous, const void *options, const unsigned int firstRow, const unsigned int numberRows)
 Converts a subset of a frame with generic pixel format (e.g., RGBA32, BGR24, YUV24, ...) to a frame with generic pixel format (e.g., Y8). More...
 
static void convertArbitraryPixelFormatSubset (const void **sources, void **targets, const unsigned int width, const unsigned int height, const ConversionFlag flag, const unsigned int multipleRowsPerIteration, const MultipleRowsConversionFunction multipleRowsConversionFunction, const void *options, const unsigned int firstMultipleRow, const unsigned int numberMultipleRows)
 Converts a subset of a frame with arbitrary pixel format (e.g., Y_UV12, Y_VU12, YUYV16, ...) to a frame with arbitrary pixel format. More...
 
static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 This function is not used anymore due to the corresponding 2-row function. More...
 
static void convertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 This function is not used anymore due to the corresponding 2-row function. More...
 
static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e.g., an RGB24 pixel format with 6 bit precision. More...
 
static void convertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e.g., an RGB24 pixel format with 10 bit precision. More...
 
static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a RGB pixel format to two rows of an image with e.g., an Y_UV12 pixel format with 7 bit precision. More...
 
static void convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a RGB pixel format to two rows of an image with e.g., an Y_U_V12 pixel format with 7 bit precision. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapOneRow_3Plane1Channel_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts (maps) one row of an image with e.g., a Y_U_V24 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapOneRow_1Plane3Channels_To_3Plane1Channel_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts (maps) one row of an image with e.g., a RGB24 pixel format to one row of an image with e.g., a R_G_B24 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts (matches) one row of an image with e.g., a Y_UV12 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts (matches) two rows of an image with e.g., a Y_UV12 pixel format to two rows of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
static void convertOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e.g., an RGB24 pixel format with 10 bit precision. More...
 
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an RGB24 pixel format with 10 bit precision. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a YUV24 pixel format to two rows of an image with e.g., an Y_U_V12 or Y_V_U12 pixel format. More...
 
static void convertOneRow_3Planes1Channel_To_1Plane3Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e.g., an RGB24 pixel format. More...
 
static void convertOneRow_3Planes1Channel_To_1Plane4Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a Y_U_V24 pixel format to one rows of an image with e.g., an RGBA32 pixel format. More...
 
static void convertOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane4Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a Y_U_V12 pixel format to one row of an image with e.g., an RGBA32 pixel format. More...
 
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an RGB24 pixel format. More...
 
static void convertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane4Channels_8BitPerChannel_Precision6Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with e.g., a Y_U_V12 pixel format to two rows of an image with e.g., an RGBA32 pixel format. More...
 
static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel_Precision10Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a YUYV16 pixel format to one row of an image with e.g., an RGB24 or BGR2424 pixel format. More...
 
static void convertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel_Precision10Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a UYVY16 pixel format to one row of an image with e.g., an RGB24 or BGR2424 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a YUYV16 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
template<unsigned int tSourceChannelIndex0, unsigned int tSourceChannelIndex1, unsigned int tSourceChannelIndex2>
static void mapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts one row of an image with e.g., a UYVY16 pixel format to one row of an image with e.g., an YUV24 or YVU24 pixel format. More...
 
template<unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel values to an image with 3-channel un-packed 8-bit pixel format. More...
 
template<unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels16Bit (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel values to an image with 3-channel un-packed 16-bit pixel format. More...
 
template<unsigned int tIndexRed, unsigned int tIndexGreen, unsigned int tIndexBlue>
static void convertTwoRows_1PlaneMosaicPacked10Bit_To_1PlaneUnpacked3Channels8BitAdvanced (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Converts two rows of an image with 3-channel Bayer mosaic pixel format with packed 10-bit pixel values to an image with 3-channel un-packed 8-bit pixel format and applies black level subtraction, white balance, and gamma encoding The layout of the parameters, options, is defined in the struct RGGB10ToRGB24AdvancedOptions. More...
 
static void mapOneRow_1Plane2Channels_To_2Planes1Channel_8BitPerChannel (const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Maps one row of a 1-plane, 2-channel image to two planes with 1 channels. More...
 
static OCEAN_FORCE_INLINE void unpack5ElementsBayerMosaicPacked10Bit (const uint8_t *const packed, uint16_t *unpacked)
 Unpacks 5 elements from a row in a packed Bayer mosaic to 4 pixels values The required memory layout of the input: A B C D X ... Bytes marked as X store two bits for each of the previous four elements: X = AABB CCDD. More...
 
template<bool tAllowLastOverlappingElement>
static OCEAN_FORCE_INLINE void unpack15ElementsBayerMosaicPacked10BitNEON (const uint8_t *const packed, uint16x8_t &unpackedAB_u_16x8, uint16x4_t &unpackedC_u_16x4)
 Unpacks 15 elements from a row in a packed Bayer mosaic to 12 pixels values The required memory layout of the input: A B C D X A B C D X A B C D X A ... Bytes marked as X store two bits for each of the previous four elements: X = AABB CCDD. More...
 
template<>
OCEAN_FORCE_INLINE void cast16Elements (const uint8_t *const source, float *const target)
 
template<>
OCEAN_FORCE_INLINE void cast16Elements (const uint8_t *const source, uint16_t *const target)
 
template<>
OCEAN_FORCE_INLINE void cast16Elements (const uint8_t *const source, int16_t *const target)
 
template<>
OCEAN_FORCE_INLINE void cast16Elements (const uint8_t *const source, uint32_t *const target)
 
template<>
OCEAN_FORCE_INLINE void cast16Elements (const uint8_t *const source, int32_t *const target)
 
template<>
OCEAN_FORCE_INLINE void cast16Elements (const float *const source, uint8_t *const target)
 

Additional Inherited Members

- Public Types inherited from Ocean::CV::FrameConverter
enum  ConversionFlag : uint32_t { CONVERT_NORMAL , CONVERT_FLIPPED , CONVERT_MIRRORED , CONVERT_FLIPPED_AND_MIRRORED }
 Definition of individual conversion flags. More...
 
enum  CopyPreference : bool { CP_AVOID_COPY_IF_POSSIBLE = false , CP_ALWAYS_COPY = true }
 Definition of a boolean enum for copy preferences (to improve code readability). More...
 
using ConversionFlags = std::vector< ConversionFlag >
 Definition of a vector holding conversion flags. More...
 
- Public Member Functions inherited from Ocean::CV::FrameConverter
template<typename TSource , typename TTarget >
OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC void cast (const TSource *__restrict source, TTarget *__restrict target, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
 
template<typename TSource , typename TTarget >
OCEAN_FORCE_INLINE void cast16Elements (const TSource *const source, TTarget *const target)
 
- Protected Types inherited from Ocean::CV::FrameConverter
template<typename TSource , typename TTarget >
using RowConversionFunction = void(*)(const TSource *sourceRow, TTarget *targetRow, const size_t width, const void *options)
 Definition of a function pointer to a function able to convert one image row from one generic pixel format to another generic pixel format. More...
 
using MultipleRowsConversionFunction = void(*)(const void **sources, void **targets, const unsigned int multipleRowIndex, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const void *options)
 Definition of a function pointer to a function able to convert multiple image row from an arbitrary pixel format to another arbitrary pixel format. More...
 
template<typename T >
using RowReversePixelOrderFunction = void(*)(const T *inputRow, T *targetRow, const size_t width)
 Definition of a function pointer to a function able to reverse the order of pixels in an image row with a generic pixel format. More...
 
template<typename T >
using RowReversePixelOrderInPlaceFunction = void(*)(T *row, const size_t width)
 Definition of a function pointer to a function able to reverse the order of pixels in an image row with a generic pixel format in-place. More...
 

Detailed Description

This class implements frame converters dividing a frame by application of a threshold.

Member Function Documentation

◆ calculateOtsuThreshold()

static uint8_t Ocean::CV::FrameConverterThreshold::calculateOtsuThreshold ( const uint8_t *  source,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
Worker worker = nullptr 
)
static

Calculate binarization threshold for a given image by application of the Otsu algorithm.

The implementation follows the work of N. Otsu: "A threshold selection method from gray-level histograms", IEEE Trans. Systems, Man and Cybernetics 9(1), pp. 62-66, 1979.

Parameters
sourceThe source frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computational load
Returns
Returns binarization threshold, with range [0, 255]
See also
convertY8ToB8()

The following tutorial shows how this function may be used:

bool applyOtsu(const Frame& source, Frame& target, Worker* worker)
{
Frame yFrame;
{
ocean_assert(false && "Unsupported pixel format!");
return false;
}
const uint8_t otsuThreshold = CV::FrameConverterThreshold::calculateOtsuThreshold(yFrame.constdata<uint8_t>(), yFrame.width(), yFrame.height(), yFrame.paddingElements(), worker);
if (!target.set(yFrame.frameType(), true, true))
{
return false;
}
CV::FrameConverterThreshold::convertY8ToB8(yFrame.constdata<uint8_t>(), target.data<uint8_t>(), yFrame.width(), yFrame.height(), yFrame.paddingElements(), target.paddingElements(), otsuThreshold, worker);
return true;
}
static bool convert(const Frame &source, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, Frame &target, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
@ CP_AVOID_COPY_IF_POSSIBLE
Tries to avoid copying the frame data whenever possible.
Definition: FrameConverter.h:96
static void convertY8ToB8(uint8_t *buffer, const unsigned int width, const unsigned int height, const unsigned int bufferPaddingElements, const uint8_t threshold, Worker *worker=nullptr)
Converts an 8 bit (grayscale) frame into a binary frame using a threshold value.
Definition: FrameConverterThreshold.h:173
static uint8_t calculateOtsuThreshold(const uint8_t *source, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, Worker *worker=nullptr)
Calculate binarization threshold for a given image by application of the Otsu algorithm.
@ FORMAT_Y8
Pixel format for grayscale images with byte order Y and 8 bits per pixel.
Definition: Frame.h:594

◆ convertBorderedY8ToB8()

void Ocean::CV::FrameConverterThreshold::convertBorderedY8ToB8 ( const uint8_t *  source,
const uint32_t *  sourceBorderedIntegral,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  sourceBorderedIntegralPaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  kernelSize,
const float  threshold,
Worker worker = nullptr 
)
inlinestatic

Converts a gray scale frame into a second binary frame using a relative threshold and a kernel size.

Instead using the gray scale frame only, additional the bordered integral image of the gray scale image is used.
The resulting binary frame uses a relative threshold resulting in better black-white borders.
Beware: The specified kernel size must have an odd value.
Beware: The border size of the integral image must have size: (kernel - 1) / 2 be the same as the used kernel size.
The corresponding integral image can be created with IntegralImage::createBorderedImage().
The resulting target pixel values will be 0 for all input values smaller than the specified threshold value and 255 for all input values equal or larger than the specified threshold value.
Compare: Adaptive Thresholding Using the Integral Image, Bradley

Parameters
sourceThe source frame buffer of the normal 8 bit gray scale image, must be valid
sourceBorderedIntegralSource frame buffer of the integral image, must be valid
targetThe target frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
sourceBorderedIntegralPaddingElementsThe number of padding elements at the end of each source integral row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target row, in elements, with range [0, infinity)
kernelSizeSize of the kernel used for adaptive thresholding, the kernel size must be: (integralBorder * 2) + 1
thresholdThe threshold (percentage) dividing the frame adaptive into black and white, with range (0, 1)
workerOptional worker used to distribute the CPU load
See also
IntegralImage::createBorderedImage().

◆ convertBorderedY8ToB8Subset()

static void Ocean::CV::FrameConverterThreshold::convertBorderedY8ToB8Subset ( const uint8_t *  source,
const uint32_t *  sourceBorderedIntegral,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  sourceBorderedIntegralPaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  kernelSize,
const float  threshold,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Converts a gray scale frame into a second binary frame using a relative threshold and a kernel size.

Instead using the gray scale frame only, additional the bordered integral image of the gray scale image is used.
The resulting binary frame uses a relative threshold resulting in better black-white borders.
Beware: The specified kernel size must have an odd value.
Beware: The border size of the integral image must have size: (kernel - 1) / 2 be the same as the used kernel size.
The corresponding integral image can be created with IntegralImage::createBorderedImage().
The resulting target pixel values will be 0 for all input values smaller than the specified threshold value and 255 for all input values equal or larger than the specified threshold value.
Compare: Adaptive Thresholding Using the Integral Image, Bradley

Parameters
sourceThe source frame buffer of the normal 8 bit gray scale image
sourceBorderedIntegralSource frame buffer of the integral image
targetThe target frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
sourceBorderedIntegralPaddingElementsThe number of padding elements at the end of each source integral row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target row, in elements, with range [0, infinity)
kernelSizeSize of the kernel used for adaptive thresholding, the kernel size must be: (integralBorder * 2) + 1
thresholdThe threshold (percentage) dividing the frame adaptive into black and white, with range (0, 1)
firstRowFirst (including) row to convert, with range [0, height)
numberRowsNumber of rows to convert, with range [1, height - firstRow]
See also
IntegralImage::createBorderedImage().

◆ convertY8ToB8() [1/2]

void Ocean::CV::FrameConverterThreshold::convertY8ToB8 ( const uint8_t *  source,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  targetPaddingElements,
const uint8_t  threshold,
Worker worker = nullptr 
)
inlinestatic

Converts an 8 bit gray scale frame into a second binary frame using a threshold.

The resulting target pixel values will be 0 for all input values smaller than the specified threshold value and 255 for all input values equal or larger than the specified threshold value.

Parameters
sourceThe source frame buffer, must be valid
targetThe target frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target row, in elements, with range [0, infinity)
thresholdThe threshold dividing the frame into black and white, with range [1, 255]
workerOptional worker used to distribute the CPU load

◆ convertY8ToB8() [2/2]

void Ocean::CV::FrameConverterThreshold::convertY8ToB8 ( uint8_t *  buffer,
const unsigned int  width,
const unsigned int  height,
const unsigned int  bufferPaddingElements,
const uint8_t  threshold,
Worker worker = nullptr 
)
inlinestatic

Converts an 8 bit (grayscale) frame into a binary frame using a threshold value.

The resulting target pixel values will be 0 for all input values smaller than the specified threshold value and 255 for all input values equal or larger than the specified threshold value.

Parameters
bufferSource and target frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
bufferPaddingElementsThe number of padding elements at the end of each buffer row, in elements, with range [0, infinity)
thresholdThe threshold dividing the frame into black and white, with range [1, 255]
workerOptional worker used to distribute the CPU load

◆ convertY8ToB8Subset() [1/2]

static void Ocean::CV::FrameConverterThreshold::convertY8ToB8Subset ( const uint8_t *  source,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  targetPaddingElements,
const uint8_t  threshold,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Converts an 8 bit gray scale frame into a second binary frame using a threshold.

The resulting target pixel values will be 0 for all input values smaller than the specified threshold value and 255 for all input values equal or larger than the specified threshold value.

Parameters
sourceThe source frame buffer, must be valid
targetThe target frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
sourcePaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target row, in elements, with range [0, infinity)
thresholdThe threshold dividing the frame into black and white, with range [0, 255]
firstRowFirst (including) row to convert, with range [0, height)
numberRowsNumber of rows to convert, with range [1, height - firstRow]

◆ convertY8ToB8Subset() [2/2]

static void Ocean::CV::FrameConverterThreshold::convertY8ToB8Subset ( uint8_t *  buffer,
const unsigned int  width,
const unsigned int  height,
const unsigned int  bufferPaddingElements,
const uint8_t  threshold,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Converts an 8 bit gray scale frame into a binary frame using a threshold.

The resulting target pixel values will be 0 for all input values smaller than the specified threshold value and 255 for all input values equal or larger than the specified threshold value.

Parameters
bufferSource and target frame buffer, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
bufferPaddingElementsThe number of padding elements at the end of each buffer row, in elements, with range [0, infinity)
thresholdThe threshold dividing the frame into black and white, with range [0, 255]
firstRowFirst (including) row to convert, with range [0, height)
numberRowsNumber of rows to convert, with range [1, height - firstRow]

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