vision.DemosaicInterpolator System object

Package: vision

Bayer-pattern image conversion to true color


The DemosaicInterpolator object demosaics Bayer's format images. The object identifies the alignment as the sequence of R, G, and B pixels in the top-left four pixels of the image, in row-wise order.


H = vision.DemosaicInterpolator returns a System object, H, that performs demosaic interpolation on an input image in Bayer format with the specified alignment.

H = vision.DemosaicInterpolator(Name,Value) returns a System object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation
Code Generation Support, Usage Notes, and Limitations.



Interpolation algorithm

Specify the algorithm the object uses to calculate the missing color information as one of Bilinear | Gradient-corrected linear. The default is Gradient-corrected linear.


Alignment of the input image

Specify 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 image. It can be set to one of RGGB |GRBG | GBRG | BGGR. The default is RGGB. Specify the sequence in left-to-right, top-to-bottom order.

 Fixed-Point Properties


cloneCreate demosaic interpolator object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepPerform demosaic operation on input


Demosaic a Bayer pattern encoded-image photographed by a camera with a sensor alignment of BGGR.

 x = imread('mandi.tif');
 hdemosaic = ...
     vision.DemosaicInterpolator('SensorAlignment', 'BGGR');
 y = step(hdemosaic, x);

 title('Original Image');
 figure, imshow(y,'InitialMagnification',20); 
 title('RGB image after demosaic');


This object implements the algorithm, inputs, and outputs described on the Demosaic block reference page. The object properties correspond to the block parameters, except:

The Output image signal block parameter allows you to specify whether the block outputs the image as One multidimensional signal or Separate color signals. The object does not have a property that corresponds to the Output image signal block parameter. The object always outputs the image as an M-by-N-by-P color video signal.
Was this topic helpful?