gdesk.panels.imgview.demosaic module

gdesk.panels.imgview.demosaic.as_float_array(array)
gdesk.panels.imgview.demosaic.bayer_split(array, pattern='RGGB')
gdesk.panels.imgview.demosaic.demosaicing_CFA_Bayer_bilinear(CFA, pattern='RGGB')

Returns the demosaiced RGB colourspace array from given Bayer CFA using bilinear interpolation.

CFAarray_like

Bayer CFA.

patternunicode, optional

{‘RGGB’, ‘BGGR’, ‘GRBG’, ‘GBRG’}, Arrangement of the colour filters on the pixel array.

ndarray

RGB colourspace array.

  • The definition output is not clipped in range [0, 1] : this allows for direct HDRI / radiance image generation on Bayer CFA data and post demosaicing of the high dynamic range data as showcased in this Jupyter Notebook.

:cite:`Losson2010c`

>>> import numpy as np
>>> CFA = np.array(
...     [[0.30980393, 0.36078432, 0.30588236, 0.3764706],
...      [0.35686275, 0.39607844, 0.36078432, 0.40000001]])
>>> demosaicing_CFA_Bayer_bilinear(CFA)
array([[[ 0.69705884,  0.17941177,  0.09901961],
        [ 0.46176472,  0.4509804 ,  0.19803922],
        [ 0.45882354,  0.27450981,  0.19901961],
        [ 0.22941177,  0.5647059 ,  0.30000001]],

       [[ 0.23235295,  0.53529412,  0.29705883],
        [ 0.15392157,  0.26960785,  0.59411766],
        [ 0.15294118,  0.4509804 ,  0.59705884],
        [ 0.07647059,  0.18431373,  0.90000002]]])
>>> CFA = np.array(
...     [[0.3764706, 0.360784320, 0.40784314, 0.3764706],
...      [0.35686275, 0.30980393, 0.36078432, 0.29803923]])
>>> demosaicing_CFA_Bayer_bilinear(CFA, 'BGGR')
array([[[ 0.07745098,  0.17941177,  0.84705885],
        [ 0.15490197,  0.4509804 ,  0.5882353 ],
        [ 0.15196079,  0.27450981,  0.61176471],
        [ 0.22352942,  0.5647059 ,  0.30588235]],

       [[ 0.23235295,  0.53529412,  0.28235295],
        [ 0.4647059 ,  0.26960785,  0.19607843],
        [ 0.45588237,  0.4509804 ,  0.20392157],
        [ 0.67058827,  0.18431373,  0.10196078]]])
gdesk.panels.imgview.demosaic.masks_CFA_Bayer(shape, pattern='RGGB')

Returns the Bayer CFA red, green and blue masks for given pattern.

shapearray_like

Dimensions of the Bayer CFA.

patternunicode, optional

{‘RGGB’, ‘BGGR’, ‘GRBG’, ‘GBRG’}, Arrangement of the colour filters on the pixel array.

tuple

Bayer CFA red, green and blue masks.

>>> from pprint import pprint
>>> shape = (3, 3)
>>> pprint(masks_CFA_Bayer(shape))
(array([[ True, False,  True],
       [False, False, False],
       [ True, False,  True]], dtype=bool),
 array([[False,  True, False],
       [ True, False,  True],
       [False,  True, False]], dtype=bool),
 array([[False, False, False],
       [False,  True, False],
       [False, False, False]], dtype=bool))
>>> pprint(masks_CFA_Bayer(shape, 'BGGR'))
(array([[False, False, False],
       [False,  True, False],
       [False, False, False]], dtype=bool),
 array([[False,  True, False],
       [ True, False,  True],
       [False,  True, False]], dtype=bool),
 array([[ True, False,  True],
       [False, False, False],
       [ True, False,  True]], dtype=bool))