prysm.bayer#
Basic operations for bayer data.
- prysm.bayer.wb_prescale(mosaic, wr, wg1, wg2, wb, cfa='rggb')#
Apply white-balance prescaling in-place to mosaic.
- Parameters
mosaic (numpy.ndarray) – ndarray of shape (m, n), a float dtype
wr (float) – red white balance prescalar
wg1 (float) – G1 white balance prescalar
wg2 (float) – G2 white balance prescalar
wb (float) – blue white balance prescalar
cfa (str, optional, {'rggb', 'bggr'}) – color filter arrangement
- prysm.bayer.wb_scale(trichromatic, wr, wg, wb)#
Apply white balance scaling in-place to trichromatic.
- Parameters
trichromatic (numpy.ndarray) – ndarray of shape (m, n, 3), a float dtype
wr (float) – red scale factor, out = in * wr
wg (float) – green scale factor, out = in * wg
wb (float) – blue scale factor, out = in * wb
- prysm.bayer.composite_bayer(r, g1, g2, b, cfa='rggb', output=None)#
Composite an interleaved image from densely sampled bayer color planes.
- Parameters
r (numpy.ndarray) – ndarray of shape (m, n)
g1 (numpy.ndarray) – ndarray of shape (m, n)
g2 (numpy.ndarray) – ndarray of shape (m, n)
b (numpy.ndarray) – ndarray of shape (m, n)
cfa (str, optional, {'rggb', 'bggr'}) – color filter arangement
output (numpy.ndarray, optional) – output array, of shape (m, n) and same dtype as r, g1, g2, b
- Returns
array of interleaved data
- Return type
numpy.ndarray
- prysm.bayer.decomposite_bayer(img, cfa='rggb')#
Decomposite an interleaved image into densely sampled color planes.
- Parameters
img (numpy.ndarray) – composited ndarray of shape (m, n)
cfa (str, optional, {'rggb', 'bggr'}) – color filter arangement
- Returns
r (numpy.ndarray) – ndarray of shape (m//2, n//2)
g1 (numpy.ndarray) – ndarray of shape (m//2, n//2)
g2 (numpy.ndarray) – ndarray of shape (m//2, n//2)
b (numpy.ndarray) – ndarray of shape (m//2, n//2)
- prysm.bayer.recomposite_bayer(r, g1, g2, b, cfa='rggb', output=None)#
Recomposite raw color planes back into a mosaic.
This function is the reciprocal of decomposite_bayer
- Parameters
r (numpy.ndarray) – ndarray of shape (m, n)
g1 (numpy.ndarray) – ndarray of shape (m, n)
g2 (numpy.ndarray) – ndarray of shape (m, n)
b (numpy.ndarray) – ndarray of shape (m, n)
cfa (str, optional, {'rggb', 'bggr'}) – color filter arangement
output (numpy.ndarray, optional) – output array, of shape (2m, 2n) and same dtype as r, g1, g2, b
- Returns
array containing the re-composited color planes
- Return type
numpy.ndarray
- prysm.bayer.demosaic_malvar(img, cfa='rggb')#
Demosaic an image using the Malvar algorithm.
- Parameters
img (numpy.ndarray) – ndarray of shape (m, n) containing mosaiced (interleaved) pixel data, as from a raw file
cfa (str, optional, {'rggb', 'bggr'}) – color filter arrangement
- Returns
ndarray of shape (m, n, 3) that has been demosaiced. Final dimension is ordered R, G, B. Is of the same dtype as img and has the same energy content and sense of z scaling
- Return type
numpy.ndarray