Colour - Demosaicing - Examples: Bayer

This notebook showcase various Bayer CFA (Colour Filter Array) related examples.

Note: All the showcased objects support an optional pattern argument specifying the arrangement of the colour filters on the pixel array: 'RGGB', 'BGGR', 'GRBG', 'GBRG'


In [1]:
from __future__ import division

import os

import colour
from colour.plotting import *

from colour_demosaicing import (
    EXAMPLES_RESOURCES_DIRECTORY,
    demosaicing_CFA_Bayer_bilinear,
    demosaicing_CFA_Bayer_Malvar2004,
    demosaicing_CFA_Bayer_Menon2007,
    mosaicing_CFA_Bayer)

cctf_encoding = colour.cctf_encoding

colour.utilities.filter_warnings()

colour.utilities.describe_environment();


===============================================================================
*                                                                             *
*   Interpreter :                                                             *
*       python : 3.7.4 (default, Sep  7 2019, 18:27:02)                       *
*                [Clang 10.0.1 (clang-1001.0.46.4)]                           *
*                                                                             *
*   colour-science.org :                                                      *
*       colour : 0.3.14                                                       *
*       colour-demosaicing : v0.1.4-48-g1a44c08                               *
*                                                                             *
*   Runtime :                                                                 *
*       imageio : 2.6.1                                                       *
*       matplotlib : 3.0.3                                                    *
*       numpy : 1.17.3                                                        *
*       scipy : 1.3.1                                                         *
*       six : 1.12.0                                                          *
*                                                                             *
===============================================================================

In [2]:
colour_style();

Data


In [3]:
LIGHTHOUSE_IMAGE = colour.io.read_image(
    os.path.join(EXAMPLES_RESOURCES_DIRECTORY, 'bayer', 'Lighthouse.exr'))

plot_image(cctf_encoding(LIGHTHOUSE_IMAGE),
           {'text': 'Lighthouse - R914108 - Kodak'});


Mosaicing


In [4]:
CFA = mosaicing_CFA_Bayer(LIGHTHOUSE_IMAGE)

plot_image(cctf_encoding(CFA),
           {'text': 'Lighthouse - CFA - RGGB'})

plot_image(cctf_encoding(mosaicing_CFA_Bayer(LIGHTHOUSE_IMAGE, 'BGGR')), 
           {'text': 'Lighthouse - CFA - BGGR'});


Demosaicing - Bilinear


In [5]:
plot_image(cctf_encoding(demosaicing_CFA_Bayer_bilinear(CFA)), 
           {'text': 'Lighthouse - Demosaicing - Bilinear'});


Demosaicing - Malvar (2004)


In [6]:
plot_image(cctf_encoding(demosaicing_CFA_Bayer_Malvar2004(CFA)), 
           {'text': 'Lighthouse - Demosaicing - Malvar (2004)'});


Demosaicing - Menon (2007)


In [7]:
plot_image(cctf_encoding(demosaicing_CFA_Bayer_Menon2007(CFA)), 
           {'text': 'Lighthouse - Demosaicing - Menon (2007)'});