CVB++ 15.0
Cvb::Foundation::BayerConversion Namespace Reference

Namespace for collection of functions converting images with a Bayer pattern. More...

Enumerations

enum class  RGBConversion { Linear = CExports::RGB_INTERPOLATE , NearestNeighbor = CExports::RGB_NEIGHBOUR , HalfResolution = CExports::RGB_HALF }
 Available conversion modes from Bayer patterns to RGB images. More...
 
enum class  BayerPattern { GreenBlue = CExports::PM_GREENBLUE , BlueGreen = CExports::PM_BLUEGREEN , RedGreen = CExports::PM_REDGREEN , GreenRed = CExports::PM_GREENRED }
 Bayer pattern of the sensor used to acquire the image to be converted. More...
 
enum class  GammaCorrection { Gamma100 = CExports::GAMMA_100 , Gamma045 = CExports::GAMMA_045 , Gamma060 = CExports::GAMMA_060 }
 Different gamma corrections that can be applied while converting from Bayer pattern to RGB. More...
 

Functions

std::unique_ptr< ImageCreateDestinationImage (int width, int height, RGBConversion mode)
 Create a destination image for Bayer to RGB conversions. More...
 
std::unique_ptr< ImageCreateDestinationImage (Size2D< int > size, RGBConversion mode)
 Create a destination image for Bayer to RGB conversions. More...
 
void BayerToRGB (const Image &imageSrc, Image &imageDst, BayerPattern pattern, RGBConversion conversion, GammaCorrection gamma=GammaCorrection::Gamma100, WhiteBalanceFactors whiteBalance=WhiteBalanceFactors::Identity())
 Convert a Bayer-pattern image to an RGB image. More...
 
std::unique_ptr< ImageBayerToRGB (const Image &image, BayerPattern pattern, RGBConversion conversion, GammaCorrection gamma=GammaCorrection::Gamma100, WhiteBalanceFactors whiteBalance=WhiteBalanceFactors::Identity())
 Convert a Bayer-pattern image to an RGB image. More...
 
std::unique_ptr< ImageBayerToMono (const Image &image, BayerPattern pattern, RGBConversion conversion, GammaCorrection gamma=GammaCorrection::Gamma100, WhiteBalanceFactors whiteBalance=WhiteBalanceFactors::Identity())
 Convert a monochrome image with a Bayer pattern to a proper monochrome image. More...
 
std::unique_ptr< ImageRGBToBayer (const Image &image, BayerPattern pattern)
 Convert an RGB image to a monochrome image with Bayer pattern. More...
 
WhiteBalanceFactors GetWhiteBalance (const Image &image, BayerPattern pattern, Area2D aoi)
 Determine a suitable white balance from a monochrome image with Bayer pattern. More...
 
WhiteBalanceFactors GetWhiteBalance (const Image &image, BayerPattern pattern)
 Determine a suitable white balance from a monochrome image with Bayer pattern. More...
 

Detailed Description

Namespace for collection of functions converting images with a Bayer pattern.

Remarks
CMake users: Link to imported target CVB::CvbFoundationBayerConversion

Enumeration Type Documentation

◆ BayerPattern

enum class BayerPattern
strong

Bayer pattern of the sensor used to acquire the image to be converted.

The enums refer to the top left pixel and the pixel next to it.

Enumerator
GreenBlue 

Left top pixels are green and blue.

BlueGreen 

Left top pixels are blue and green.

RedGreen 

Left top pixels are red and green.

GreenRed 

Left top pixels are green and red.

◆ GammaCorrection

enum class GammaCorrection
strong

Different gamma corrections that can be applied while converting from Bayer pattern to RGB.

Enumerator
Gamma100 

Correct with Gamma = 1.0 (i.e. no correction).

Gamma045 

Correct with Gamma = 0.45.

Gamma060 

Correct with Gamma = 0.6.

◆ RGBConversion

enum class RGBConversion
strong

Available conversion modes from Bayer patterns to RGB images.

Enumerator
Linear 

This method offers the highest accuracy, but also the slowest speed. Interpolation of the nearest pixels is used to calculate the two unknown color values for each position. Depending on the position of the pixel either two or four pixels are used for the interpolation. In this mode full spatial resolution is maintained.

NearestNeighbor 

This method offers the fastest speed for a full resolution image, but the color accuracy is not as high as the RGBConversion.Linear method. The color from a neighbor pixel is used for the two unknown color values. This makes the conversion faster, because there is no need for interpolation. In this method full spatial resolution is maintained.

HalfResolution 

This method is provided primarily for display. This method creates an RGB image with half the height and half the width of the source image, the color accuracy is the same as the RGBConversion.NearestNeighbor method, but half the spacial accuracy is lost. If the user needs a fast display for focusing or setup of the camera, then this method will allow higher frame rates on a suitable PC.

Function Documentation

◆ BayerToMono()

std::unique_ptr< Image > BayerToMono ( const Image image,
BayerPattern  pattern,
RGBConversion  conversion,
GammaCorrection  gamma = GammaCorrection::Gamma100,
WhiteBalanceFactors  whiteBalance = WhiteBalanceFactors::Identity() 
)
inline

Convert a monochrome image with a Bayer pattern to a proper monochrome image.

Parameters
[in]imageImage to be converted.
[in]patternPattern in the top left corner of the sensor with which image was acquired.
[in]conversionConversion method.
[in]gammaGamma correction.
[in]whiteBalanceWhite balance.
Returns
Newly created image that contains the conversion result.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ BayerToRGB() [1/2]

std::unique_ptr< Image > BayerToRGB ( const Image image,
BayerPattern  pattern,
RGBConversion  conversion,
GammaCorrection  gamma = GammaCorrection::Gamma100,
WhiteBalanceFactors  whiteBalance = WhiteBalanceFactors::Identity() 
)
inline

Convert a Bayer-pattern image to an RGB image.

Parameters
[in]imageImage to be converted.
[in]patternPattern in the top left corner of the sensor with which image was acquired.
[in]conversionConversion method.
[in]gammaGamma correction.
[in]whiteBalanceWhite balance.
Returns
Newly created image that contains the conversion result.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ BayerToRGB() [2/2]

void BayerToRGB ( const Image imageSrc,
Image imageDst,
BayerPattern  pattern,
RGBConversion  conversion,
GammaCorrection  gamma = GammaCorrection::Gamma100,
WhiteBalanceFactors  whiteBalance = WhiteBalanceFactors::Identity() 
)
inline

Convert a Bayer-pattern image to an RGB image.

Parameters
[in]imageSrcMonochrome image with the Bayer pattern to be converted.
[in]imageDstDestination to receive the conversion results (preferably created by CreateDestinationImage()).
[in]patternPattern in the top left corner of the sensor with which imageDst was acquired.
[in]conversionConversion method.
[in]gammaGamma correction.
[in]whiteBalanceWhite balance.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ CreateDestinationImage() [1/2]

std::unique_ptr< Image > CreateDestinationImage ( int  width,
int  height,
RGBConversion  mode 
)
inline

Create a destination image for Bayer to RGB conversions.

Parameters
[in]widthWidth of the input image to convert for.
[in]heightHeight of the input image to convert for.
[in]modeConversion mode to be used.
Returns
BayerToRGB destination image.
Exceptions
Anyexception derived from std::exception including CvbException.

Bayer to RGB conversions are also implemented as in-place operations, however the destination image needs to have a suitable width and height to be eligible. The destination width and height depends on the size of the input image as well as the conversion method.

◆ CreateDestinationImage() [2/2]

std::unique_ptr< Image > CreateDestinationImage ( Size2D< int >  size,
RGBConversion  mode 
)
inline

Create a destination image for Bayer to RGB conversions.

Parameters
[in]sizeSize of the input image to convert for.
[in]modeConversion mode to be used.
Returns
BayerToRGB destination image.
Exceptions
Anyexception derived from std::exception including CvbException.

Bayer to RGB conversions are also implemented as in-place operations, however the destination image needs to have a suitable width and height to be eligible. The destination width and height depend on the size of the input image as well as the conversion method.

◆ GetWhiteBalance() [1/2]

WhiteBalanceFactors GetWhiteBalance ( const Image image,
BayerPattern  pattern 
)
inline

Determine a suitable white balance from a monochrome image with Bayer pattern.

Parameters
[in]imageMonochrome image with Bayer pattern.
[in]patternPattern in the top left corner of the sensor with which image was acquired.
Returns
White balance factors.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ GetWhiteBalance() [2/2]

WhiteBalanceFactors GetWhiteBalance ( const Image image,
BayerPattern  pattern,
Area2D  aoi 
)
inline

Determine a suitable white balance from a monochrome image with Bayer pattern.

Parameters
[in]imageMonochrome image with Bayer pattern.
[in]patternPattern in the top left corner of the sensor with which the image was acquired.
[in]aoiArea in which to determine the white balance factors.
Returns
White balance factors.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ RGBToBayer()

std::unique_ptr< Image > RGBToBayer ( const Image image,
BayerPattern  pattern 
)
inline

Convert an RGB image to a monochrome image with Bayer pattern.

Parameters
[in]imageImage to be converted.
[in]patternPattern in the top left corner of the sensor with which image was acquired.
Returns
Converted image.
Exceptions
Anyexception derived from std::exception including CvbException.