Main Content

Demosaic Interpolator

Construct RGB pixel data from Bayer pattern pixels

  • Library:
  • Vision HDL Toolbox / Conversions

  • Demosaic Interpolator block

Description

The Demosaic Interpolator block provides a Bayer pattern interpolation filter for streaming video data. The block implements the calculations using hardware-efficient, multiplier-free algorithms for HDL code generation. You can select a low-complexity bilinear interpolation, or a moderate-complexity gradient-corrected bilinear interpolation.

  • When you select bilinear interpolation, the block operates on a 3×3 pixel window using only additions and bit shifts.

  • When you select gradient correction, the block operates on a 5×5 pixel window. The calculation is performed using bit shift, addition, and low-order canonical signed digit (CSD) multiplication.

Ports

This block uses a streaming pixel interface with a pixelcontrol bus for frame control signals. This interface enables the block to operate independently of image size and format. All Vision HDL Toolbox™ blocks use the same streaming interface. The block accepts and returns a scalar pixel value and a bus that contains five control signals. The control signals indicate the validity of each pixel and its location in the frame. To convert a frame (pixel matrix) into a serial pixel stream and control signals, use the Frame To Pixels block. For a full description of the interface, see Streaming Pixel Interface.

Input

expand all

Single image pixel, specified as a scalar. Images in the Bayer format have one color component for each pixel location. Select the sequence of R, G, and B pixels with the Sensor alignment parameter.

double and single data types are supported for simulation, but not for HDL code generation.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | fixed point

The pixelcontrol bus contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

Data Types: bus

Output

expand all

Single image pixel, returned as a three-element vector of RGB values. The block calculates the values of the missing color components for each pixel, using the method you specify in the Interpolation algorithm parameter.

double and single data types are supported for simulation, but not for HDL code generation.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | fixed point

The pixelcontrol bus contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

Data Types: bus

Parameters

expand all

Algorithm used to calculate missing pixel values, specified as one of the following:

  • Gradient-corrected linear — Bilinear average, corrected for intensity gradient

  • Bilinear — Average of the pixel values in the surrounding 3×3 neighborhood

Select the sequence of R, G, and B pixels that correspond to the 2-by-2 block of pixels in the top-left corner of the input image. Specify the sequence in left-to-right, top-to-bottom order. For instance, the default sequence of RGGB represents an image with this pattern.

Specify a power of two that accommodates the number of active pixels in a single horizontal line.

Choose a power of two that accommodates the number of active pixels in a horizontal line. If you specify a value that is not a power of two, the block uses the next largest power of two. The total memory size allocated depends on your selection of Interpolation algorithm:

  • Bilinear: 2-by-Line buffer size memory locations

  • Gradient-corrected linear: 4-by-Line buffer size memory locations

Tips

  • When you use a block with an internal line buffer inside an Enabled Subsystem (Simulink), the enable signal pattern must maintain the timing of the pixel stream, including the minimum blanking intervals. If the enable pattern corrupts the timing of the pixel stream, you might see partial output frames, corrupted pixel stream control signals, or mismatches between Simulink® and HDL simulation results. You may need to extend the blanking intervals to accommodate for cycles when the enable is low. For more information, see Configure Blanking Intervals.

Algorithms

expand all

The block pads the edges of the image with symmetric pixel values. For more details, see Edge Padding.

References

[1] Malvar, Henrique S., Li-wei He, and Ross Cutler. “High-Quality Linear Interpolation for Demosaicing of Bayer-Patterned Color Images.” Microsoft Research, May 2004. http://research.microsoft.com/pubs/102068/Demosaicing_ICASSP04.pdf.

Extended Capabilities

See Also

Blocks

Objects

Introduced in R2015a