Class NPPNativeMethods.NPPi.ColorDebayer
Grayscale Color Filter Array to RGB Color Debayer conversion. Generates one RGB color pixel for every grayscale source pixel.
Source and destination images must have even width and height. Missing pixel colors are generated using bilinear interpolation with chroma correlation of generated green values (eInterpolation MUST be set to 0). eGrid allows the user to specify the Bayer grid registration position at source image location oSrcROI.x, oSrcROI.y relative to pSrc. Possible registration positions are:
BGGR | RGGB | GBRG | GRBG
B G || R G || G B || G R
G R || G B || R G || B G
If it becomes necessary to access source pixels outside source image then the source image borders are mirrored.
Here is how the algorithm works. R, G, and B base pixels from the source image are used unmodified. To generate R values for those G pixels, the average of R(x - 1, y) and R(x + 1, y) or R(x, y - 1) and R(x, y + 1) is used depending on whether the left and right or top and bottom pixels are R base pixels. To generate B values for those G pixels, the same algorithm is used using nearest B values. For an R base pixel, if there are no B values in the upper, lower, left, or right adjacent pixels then B is the average of B values in the 4 diagonal (G base) pixels. The same algorithm is used using R values to generate the R value of a B base pixel. Chroma correlation is applied to generated G values only, for a B base pixel G(x - 1, y) and G(x + 1, y) are averaged or G(x, y - 1) and G(x, y + 1) are averaged depending on whether the absolute difference between B(x, y) and the average of B(x - 2, y) and B(x + 2, y) is smaller than the absolute difference between B(x, y) and the average of B(x, y - 2) and B(x, y + 2). For an R base pixel the same algorithm is used testing against the surrounding R values at those offsets. If the horizontal and vertical differences are the same at one of those pixels then the average of the four left, right, upper and lower G values is used instead.
Inheritance
Inherited Members
Namespace: ManagedCuda.NPP
Assembly: NPP.dll
Syntax
public static class ColorDebayer
Methods
nppiCFAToRGB_16u_C1C3R(CUdeviceptr, Int32, NppiSize, NppiRect, CUdeviceptr, Int32, NppiBayerGridPosition, InterpolationMode)
1 channel 16-bit unsigned packed CFA grayscale Bayer pattern to 3 channel 16-bit unsigned packed RGB conversion.
Declaration
public static NppStatus nppiCFAToRGB_16u_C1C3R(CUdeviceptr pSrc, int nSrcStep, NppiSize oSrcSize, NppiRect oSrcROI, CUdeviceptr pDst, int nDstStep, NppiBayerGridPosition eGrid, InterpolationMode eInterpolation)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | pSrc | Source-Image Pointer. |
System.Int32 | nSrcStep | Source-Image Line Step. |
NppiSize | oSrcSize | \ref full source image width and height relative to pSrc. |
NppiRect | oSrcROI | \ref rectangle specifying starting source image pixel x and y location relative to pSrc and ROI width and height. |
CUdeviceptr | pDst | Destination-Image Pointer. |
System.Int32 | nDstStep | Destination-Image Line Step. |
NppiBayerGridPosition | eGrid | enumeration value specifying bayer grid registration position at location oSrcROI.x, oSrcROI.y relative to pSrc. |
InterpolationMode | eInterpolation | MUST be Undefined |
Returns
Type | Description |
---|---|
NppStatus | StepError, NotEvenStepError, NullPointerError, AlignmentError, StepError, SizeError |
nppiCFAToRGB_8u_C1C3R(CUdeviceptr, Int32, NppiSize, NppiRect, CUdeviceptr, Int32, NppiBayerGridPosition, InterpolationMode)
1 channel 8-bit unsigned packed CFA grayscale Bayer pattern to 3 channel 8-bit unsigned packed RGB conversion.
Declaration
public static NppStatus nppiCFAToRGB_8u_C1C3R(CUdeviceptr pSrc, int nSrcStep, NppiSize oSrcSize, NppiRect oSrcROI, CUdeviceptr pDst, int nDstStep, NppiBayerGridPosition eGrid, InterpolationMode eInterpolation)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | pSrc | Source-Image Pointer. |
System.Int32 | nSrcStep | Source-Image Line Step. |
NppiSize | oSrcSize | \ref full source image width and height relative to pSrc. |
NppiRect | oSrcROI | \ref rectangle specifying starting source image pixel x and y location relative to pSrc and ROI width and height. |
CUdeviceptr | pDst | Destination-Image Pointer. |
System.Int32 | nDstStep | Destination-Image Line Step. |
NppiBayerGridPosition | eGrid | enumeration value specifying bayer grid registration position at location oSrcROI.x, oSrcROI.y relative to pSrc. |
InterpolationMode | eInterpolation | MUST be Undefined |
Returns
Type | Description |
---|---|
NppStatus | StepError, NotEvenStepError, NullPointerError, AlignmentError, StepError, SizeError |
nppiCFAToRGBA_16u_C1AC4R(CUdeviceptr, Int32, NppiSize, NppiRect, CUdeviceptr, Int32, NppiBayerGridPosition, InterpolationMode, UInt16)
1 channel 16-bit unsigned packed CFA grayscale Bayer pattern to 4 channel 16-bit unsigned packed RGB conversion with alpha.
Declaration
public static NppStatus nppiCFAToRGBA_16u_C1AC4R(CUdeviceptr pSrc, int nSrcStep, NppiSize oSrcSize, NppiRect oSrcROI, CUdeviceptr pDst, int nDstStep, NppiBayerGridPosition eGrid, InterpolationMode eInterpolation, ushort nAlpha)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | pSrc | Source-Image Pointer. |
System.Int32 | nSrcStep | Source-Image Line Step. |
NppiSize | oSrcSize | \ref full source image width and height relative to pSrc. |
NppiRect | oSrcROI | \ref rectangle specifying starting source image pixel x and y location relative to pSrc and ROI width and height. |
CUdeviceptr | pDst | Destination-Image Pointer. |
System.Int32 | nDstStep | Destination-Image Line Step. |
NppiBayerGridPosition | eGrid | enumeration value specifying bayer grid registration position at location oSrcROI.x, oSrcROI.y relative to pSrc. |
InterpolationMode | eInterpolation | MUST be Undefined |
System.UInt16 | nAlpha | constant alpha value to be written to each destination pixel |
Returns
Type | Description |
---|---|
NppStatus | StepError, NotEvenStepError, NullPointerError, AlignmentError, StepError, SizeError |
nppiCFAToRGBA_8u_C1AC4R(CUdeviceptr, Int32, NppiSize, NppiRect, CUdeviceptr, Int32, NppiBayerGridPosition, InterpolationMode, Byte)
1 channel 8-bit unsigned packed CFA grayscale Bayer pattern to 4 channel 8-bit unsigned packed RGB conversion with alpha.
Declaration
public static NppStatus nppiCFAToRGBA_8u_C1AC4R(CUdeviceptr pSrc, int nSrcStep, NppiSize oSrcSize, NppiRect oSrcROI, CUdeviceptr pDst, int nDstStep, NppiBayerGridPosition eGrid, InterpolationMode eInterpolation, byte nAlpha)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | pSrc | Source-Image Pointer. |
System.Int32 | nSrcStep | Source-Image Line Step. |
NppiSize | oSrcSize | \ref full source image width and height relative to pSrc. |
NppiRect | oSrcROI | \ref rectangle specifying starting source image pixel x and y location relative to pSrc and ROI width and height. |
CUdeviceptr | pDst | Destination-Image Pointer. |
System.Int32 | nDstStep | Destination-Image Line Step. |
NppiBayerGridPosition | eGrid | enumeration value specifying bayer grid registration position at location oSrcROI.x, oSrcROI.y relative to pSrc. |
InterpolationMode | eInterpolation | MUST be Undefined |
System.Byte | nAlpha | constant alpha value to be written to each destination pixel |
Returns
Type | Description |
---|---|
NppStatus | StepError, NotEvenStepError, NullPointerError, AlignmentError, StepError, SizeError |