The default image extension mode used in scipy.ndimage.convolve is 'reflect', which reflects the image about the edge of the pixels. This introduces artefacts in the edge of the resulting RGB layers when demosaicing:
# Constant ones as image
orig = np.ones((2,2))
R, G, B = demosaicing_CFA_Bayer_bilinear(orig)
# R, G and B should also be constant 1 (at least in the measured pixels), but instead
# R: [[2.25, 0.75], G: [[0.5, 1.5], B: [[0.25, 0.75],
# [0.75, 0.25]] [1.5, 0.5]] [0.75, 2.25]]
Passing mode='mirror' - which reflects about pixel centers (doesn't repeat the edge values) - to convolve in demosaicing_CFA_Bayer_bilinear returns the expected values. I figure this should be the default for demosaicing?
The default image extension mode used in
scipy.ndimage.convolveis'reflect', which reflects the image about the edge of the pixels. This introduces artefacts in the edge of the resulting RGB layers when demosaicing:Passing
mode='mirror'- which reflects about pixel centers (doesn't repeat the edge values) - toconvolveindemosaicing_CFA_Bayer_bilinearreturns the expected values. I figure this should be the default for demosaicing?