QuadBayer CFA Modified Gradient-Based Demosaicing

A modified gradient-based de-mosaic algorithm for quad-bayer color filter array with quarter-res and full-res output.


Updated 18 Sep 2022

View License

This is a modified gradient-based Quad Bayer demosaicing algorithm.
Expanded from CFA Interpolation Detection by Leszek Swirski (Nov 30, 2009) which can be found here: https://www.cl.cam.ac.uk/teaching/0910/R08/work/essay-ls426-cfadetection.pdf
What's Quad Bayer CFA? You can find here:
Function "sampling_quad_bayer" is used to generate Quad Bayer CFA RAW images.
Function "quad_bayer_demosaic_full" is used as a full resolution output.
Function "quad_bayer_demosaic_quarter" is used as a quarter resolution output and shifted the image by 0.5px in both directions.
Function "quad_bayer_demosaic_binning" is used as a demosaicing tool of binning bayer image.

Cite As

Rainbow-Johnny-Johnny-Image-Processing-Lim (2023). QuadBayer CFA Modified Gradient-Based Demosaicing (https://www.mathworks.com/matlabcentral/fileexchange/116085-quadbayer-cfa-modified-gradient-based-demosaicing), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Bayer_demosaic: Edge bugs of red and blue color were reduced.

Enhancing the Resolution of Binning Bayer Mode.

hotfix of

Bugs Fixed, SSIM Improved of Binning Mode.

Brings the gradient values of the green channel into the interpolation of the red and blue channels, significantly improving the resolution of the red/blue channels. Also, reduces the problem of oblique false color below a certain frequency.

Function rewriting to enhance the SSIM and PSNR of realistic input images.

Added New Criterion to enhance SSIM.

Reduce artifactual color problems and improve interpolation accuracy.


Bug fixed


Added Binning Bayer Demosaicing, PSNR Improved.


Added auto-crop.


And QB CFA Fake Color Image.