GithubHelp home page GithubHelp logo

colour-science / colour-demosaicing Goto Github PK

View Code? Open in Web Editor NEW
267.0 18.0 57.0 78.31 MB

CFA (Colour Filter Array) Demosaicing Algorithms for Python

Home Page: https://www.colour-science.org

License: BSD 3-Clause "New" or "Revised" License

Python 1.19% TeX 0.08% Jupyter Notebook 98.72%
cfa bayer color color-science color-space color-spaces colorspace colorspaces colour colour-science

colour-demosaicing's Introduction

Hi! We are colour-science ๐Ÿ‘‹

We are the maintainers of Colour and the related projects at colour-science.

Colour is our contribution to Open Source Software with a library that people can use to validate their colorimetric computations and grow their knowledge about light and colour: Google engineers used it to improve Youtube colour processing correctness!

We are also involved with many Open Source Software projects such as the Academy Color Encoding System (ACES) or OpenColorIO and try to spread as much as possible the knowledge about colorimetry.

Social

colour-demosaicing's People

Contributors

hahnec avatar kelsolaar avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colour-demosaicing's Issues

How to save the image correctly?

hi
thanks for this lib. I have a question about saving img.
I can use the plot to plot a correct color img, however, I don't know how to save it correctly. The color in the saved img is quite different from the plotting. Will you please show a example of img saving?

Git fatal message upon import.

Getting the following message upon importing:

fatal: Not a git repository (or any of the parent directories): .git

Started ~ a month ago.

Error when using colour import on Win10 Python 3.7.9

Hi,
Trying to use your library for demosaic RAW16 -> RGB images and for some reason getting 'The specified module could not be found', despite the fact that installed all prerequisites listed and VC code can see colour package as locally installed, any help will be appreciated.

image

image

Investigate potential overflows in the complex demosaicing definitions.

I am using this with a point grey camera, and I get some weird artifacts while using the demosaicing_CFA_Bayer_DDFAPD, demosaicing_CFA_Bayer_Malvar2004, and demosaicing_CFA_Bayer_Menon2007 methods.
The method demosaicing_CFA_Bayer_bilinear doesn't seem to have that problem.

They look like these blue dots. I am thinking that the colors are overflowing the byte.
screen shot 2016-10-05 at 12 57 01 pm

Colour shift issue for with Malvar (2004) demosaicing.

Hi,
I met a problem that using Malvar04 can not convert white space correctly.
image.
The left image is the originally space image, the middle image is the bayer image, the right is the output of the Malvar04. Can you help me to solve this problem?
Also, the result of the bluid-in code in matlab works fine. Matlab results:
image
To note that, the bayer images are the same in matlab and python.

Default convolution mode introduces edge effects

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?

Is "colour-demosaicing" available in Anaconda?

I would like to use colour_demosaicing in my python script as follows:
from colour_demosaicing import demosaicing_CFA_Bayer_bilinear as demosaic
I installed colour-science with conda install -c conda-forge colour-science but I get the following error:

Traceback (most recent call last):
  File "robotcar.py", line 12, in <module>
    from colour_demosaicing import demosaicing_CFA_Bayer_bilinear as demosaic
ImportError: No module named colour_demosaicing

Is there any other package library I should install in conda env to import colour_demosaicing ?

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

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.

How to make demosaicing function return RGB values in [0,1] range?

Hi, @KelSolaar , thanks a lot for the lib.
I noticed that the demosaicing function does not return the output in [0,1] range, how can I make it in [0,1] range?

def demosaicing_CFA_Bayer_bilinear(CFA, pattern='RGGB'):
Notes
    -----
    -   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 <https://github.com/colour-science/colour-hdri/\
blob/develop/colour_hdri/examples/\
examples_merge_from_raw_files_with_post_demosaicing.ipynb>`__.

The dev dependency `pytest-xdist` is always installed

Description

The dependency pytest-xdist is not listed in the extra development and is always installed since version 0.2.2. This brings even more dependencies not needed at runtime.

Code for Reproduction

No response

Exception Message

No response

Environment Information

No response

Demosaicing does not return clipped values

Demosaicing a normalized bayer image with float values between 0 and 1 using the demosaicing_CFA_Bayer_Malvar2004 method does not return a clipped image. This should either be mentioned in the documentation or demosaicing methods should finish with an appropriate clipping step since without noticing this behaviour the resulting PSNRs are significantly worse.

[BUG]: Exit without throwing an exception

Description

Hey folks,

I am a frequent user of your library and made it even part of my own project PlenoptiCam, where I recently encountered a problem, which I believe is due to the colour-demosaicing software library. Raw images passed to PlenoptiCam are relativey large in terms of their spatial resolution, thus requiring a large amount of memory. I observed that occasionally my software quit at some point without throwing an error or exception. When debugging, I noticed that this behaviour occurs at a point of my pipeline where the rather costly demosaicing_CFA_Bayer_Menon2007 function is called. I attempted to reproduce the problem with a synthetic image having a very large image resolution and observed the same problem: program abort without any message. Below you can find a short code example causing this issue on my machine.

While it is obvious why this error occurs, I would like to have a little control about the case when it happens. Would it be possible to throw an exception just before the function call crashes? This would allow users to keep programs running and let them know about the cause of the problem.

Code for Reproduction

import numpy as np
from colour_demosaicing import demosaicing_CFA_Bayer_Menon2007

mockup_image = np.ones([int(1e4), int(1e4)])
res = demosaicing_CFA_Bayer_Menon2007(CFA=mockup_image, pattern="RGGB", refining_step=True)

Exception Message

An Exception would be desired, but unfortunately there is no.

Environment Information

===============================================================================
*                                                                             *
*   Interpreter :                                                             *
*       python : 3.8.10 (default, Mar 15 2022, 12:22:08)                      *
*                [GCC 9.4.0]                                                  *
*                                                                             *
*   colour-science.org :                                                      *
*       colour : 0.4.1                                                        *
*       colour-demosaicing : 0.2.1                                            *
*                                                                             *
*   Runtime :                                                                 *
*       imageio : 2.16.1                                                      *
*       matplotlib : 3.5.1                                                    *
*       networkx : 2.7.1                                                      *
*       numpy : 1.22.3                                                        *
*       scipy : 1.8.0                                                         *
*                                                                             *
===============================================================================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.