Convert Bayer pattern encoded image to truecolor image
RGB = demosaic(I,sensorAlignment)
A Bayer filter mosaic, or color filter array, refers to the
arrangement of color filters that let each sensor in a single-sensor
digital camera record only red, green, or blue data. The patterns
emphasize the number of green sensors to mimic the human eye's greater
sensitivity to green light. The
uses interpolation to convert the two-dimensional Bayer-encoded image
into the truecolor image.
Code Generation support: Yes.
MATLAB Function Block support: Yes.
Convert a Bayer pattern encoded image that was photographed by a camera with a sensor alignment of
I = imread('mandi.tif'); J = demosaic(I,'bggr'); imshow(I); figure, imshow(J);
I— Bayer-pattern encoded imageM-by-N array of intensity values
Bayer-pattern encoded image, specified as an M-by-N array
of intensity values.
I must have at least 5 rows
and 5 columns.
sensorAlignment— Bayer pattern (default) | string
Bayer pattern, specified as one of the strings in the following table. Each string represents the order of the red, green, and blue sensors by describing the four pixels in the upper-left corner of the image (left-to-right, top-to-bottom).
|String||2–by-2 Sensor Alignment|
This function supports the generation of C code using MATLAB® Coder™. For more information, see Code Generation for Image Processing.
When generating code, note the following:
sensorAlignment must be a compile-time
You can use this function in the MATLAB Function Block in Simulink.
 Malvar, H.S., L. He, and R. Cutler, High quality linear interpolation for demosaicing of Bayer-patterned color images. ICASPP, Volume 34, Issue 11, pp. 2274-2282, May 2004.