Main Content

Demosaic an Image

This example shows you how to demosaic a Bayer-pattern image.

Example Model

Open the Simulink® model.

modelname = "ex_blkDemosaic.slx";
open_system(modelname)

The model reads an input image using an Image From File block with the File name parameter set to mandi.tif and the Sample time parameter set to inf. To demosaic the input image, the model uses a Demosaic block with the Sensor alignment set to BGGR.

Simulate the Model

Run the model. The Video Viewer blocks display the input image and the output image. You can zoom out to better inspect the images.

sim(modelname)

Figure Output Image contains an axes object and other objects of type uiflowcontainer, uimenu, uitoolbar. The hidden axes object contains an object of type image.

Figure Input Image contains an axes object and other objects of type uiflowcontainer, uimenu, uitoolbar. The hidden axes object contains an object of type image.

ans = 
  Simulink.SimulationOutput:
                   tout: [51x1 double] 

     SimulationMetadata: [1x1 Simulink.SimulationMetadata] 
           ErrorMessage: [0x0 char]