colour-science / colour-demosaicing

CFA (Colour Filter Array) demosaicing algorithms for Python
https://www.colour-science.org
BSD 3-Clause "New" or "Revised" License
285 stars 58 forks source link

Visible clipping artifacts in highlights with Malvar (2004) and Menon (2007). #7

Closed jiawen closed 6 years ago

jiawen commented 6 years ago

My apologies ahead of time for not posting images as I am uncertain whether I have the appropriate rights.

I just tried demosaicing_CFA_Bayer_Malvar2004() and demosaicing_CFA_Bayer_Menon2007() on the standard MATLAB test image "mandi.tif" (see https://www.mathworks.com/help/images/ref/demosaic.html).

With the Malvar method, I see distinctive speckles of pure red and blue in the output near highlights. Besides that, the results are basically identical to that of MATLAB.

With the Menon method, there are pure red, green, and blue everywhere.

I suspect these are some bugs in the way overflow and underflow are handled.

KelSolaar commented 6 years ago

Hi @jiawen,

I could not reproduce the issue:

import colour
import colour_demosaicing

RGB = colour_demosaicing.demosaicing_CFA_Bayer_Menon2007(
    colour.read_image('mandi.tif'), 'BGGR')

colour.write_image(RGB, 'mandi_Menon2007.jpg')

Malvar (2004) image

Menon (2007) image

How are you invoking the function(s)?

jiawen commented 6 years ago

My apologies for the delay as I got distracted by other stuff at work. Maybe it's because I'm reading the input using skimage.io.imread() instead of colour.read_image()?

Anyway, here's the IPython notebook I was using, and this is the output from Malvar.

jiawen commented 6 years ago

I'm using colour-demosaicing 0.1.2 installed from pip on Python 3.6.

I'm not using colour.read_image() mainly because I have no idea how to easily install OpenImageIO into Anaconda without installing it system-wide.

jiawen commented 6 years ago

Output from Menon

KelSolaar commented 6 years ago

@jiawen : I will try to look at that over the weekend, by the mean time can you try converting the array you get from skimage.io.imread to float and maybe divide it by 255 or 65535 before passing it to demosaicing_CFA_Bayer_Menon2007?

Cheers,

Thomas

KelSolaar commented 6 years ago

Hi @jiawen,

I'm closing this for now, feel free to continue the discussion though.

Cheers,

Thomas