A Python package implementing various CFA (Colour Filter Array) demosaicing algorithms and related utilities.

Overview

Colour - Demosaicing

Develop Build Status Coverage Status Code Grade Package Version

A Python package implementing various CFA (Colour Filter Array) demosaicing algorithms and related utilities.

It is open source and freely available under the New BSD License terms.

https://raw.githubusercontent.com/colour-science/colour-demosaicing/master/docs/_static/Demosaicing_001.png

1   Features

The following CFA (Colour Filter Array) demosaicing algorithms are implemented:

  • Bilinear
  • Malvar (2004)
  • DDFAPD - Menon (2007)

2   Installation

Because of their size, the resources dependencies needed to run the various examples and unit tests are not provided within the Pypi package. They are separately available as Git Submodules when cloning the repository.

2.1   Primary Dependencies

Colour - Demosaicing requires various dependencies in order to run:

2.2   Pypi

Once the dependencies are satisfied, Colour - Demosaicing can be installed from the Python Package Index by issuing this command in a shell:

pip install --user colour-demosaicing

The overall development dependencies are installed as follows:

pip install --user 'colour-demosaicing[development]'

3   Usage

3.1   API

The main reference for Colour - Demosaicing is the Colour - Demosaicing Manual.

3.2   Examples

Various usage examples are available from the examples directory.

4   Contributing

If you would like to contribute to Colour - Demosaicing, please refer to the following Contributing guide for Colour.

5   Bibliography

The bibliography is available in the repository in BibTeX format.

6   Code of Conduct

The Code of Conduct, adapted from the Contributor Covenant 1.4, is available on the Code of Conduct page.

7   Contact & Social

The Colour Developers can be reached via different means:

8   About

Colour - Demosaicing by Colour Developers
Copyright © 2015-2021 – Colour Developers – [email protected]
This software is released under terms of New BSD License: https://opensource.org/licenses/BSD-3-Clause
Comments
  • PR: Add garbage collection to reduce memory consumption.

    PR: Add garbage collection to reduce memory consumption.

    Summary

    Added explicit deletion of temporary variables to reduce the memory consumption of the demosaicing methods.

    Description

    In particular for the demosaicing method by Menon, I have noticed a huge memory consumption. In one particular case I was not able to demosaic a large image (around 7000 x 5000) with 14 GB of available memory. By introducing the explicit deletion, I was able to tone it down to 5 GB in that particular case. I've added the garbage collection to the other demosaicing methods as well, even though the gain in memory usage is not as big.

    opened by MaxSchambach 20
  • [BUG]: Exit without throwing an exception

    [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                                                         *
    *                                                                             *
    ===============================================================================
    
    Defect 
    opened by hahnec 13
  • Is

    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 ?

    opened by mrgransky 11
  • Error when using colour import on Win10 Python 3.7.9

    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

    API Discussion 
    opened by gennadyg 6
  • Visible clipping artifacts in highlights with Malvar (2004) and Menon (2007).

    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.

    API Discussion 
    opened by jiawen 6
  • Why is brightness changing when using the Malvar algorithm?

    Why is brightness changing when using the Malvar algorithm?

    Hi, When using the Malvar algorithm I get an output image which is much brighter than the original input image. This change is different for different images. What is the reason this happens?

    API Discussion 
    opened by song4me 4
  • How to make demosaicing function return RGB values in [0,1] range?

    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>`__.
    
    API Discussion 
    opened by Jiazheng411 3
  • PR: Support for pixels with a value of zero.

    PR: Support for pixels with a value of zero.

    The existing convolutions caused pixels with a value of zero to underflow. Problem is solved by performing floating point convolutions, and clipping negative pixel values to zero. nb. scipy.signal dependency is added

    opened by MadsDyrmann 3
  • Demosaicing does not return clipped values

    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.

    API Discussion 
    opened by timmeinhardt 3
  • Investigate potential overflows in the complex demosaicing definitions.

    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

    Task 
    opened by m0ose 3
  • Bump bleach from 3.2.1 to 3.3.0

    Bump bleach from 3.2.1 to 3.3.0

    Bumps bleach from 3.2.1 to 3.3.0.

    Changelog

    Sourced from bleach's changelog.

    Version 3.3.0 (February 1st, 2021)

    Backwards incompatible changes

    • clean escapes HTML comments even when strip_comments=False

    Security fixes

    • Fix bug 1621692 / GHSA-m6xf-fq7q-8743. See the advisory for details.

    Features

    None

    Bug fixes

    None

    Version 3.2.3 (January 26th, 2021)

    Security fixes

    None

    Features

    None

    Bug fixes

    • fix clean and linkify raising ValueErrors for certain inputs. Thank you @Google-Autofuzz.

    Version 3.2.2 (January 20th, 2021)

    Security fixes

    None

    Features

    • Migrate CI to Github Actions. Thank you @hugovk.

    Bug fixes

    • fix linkify raising an IndexError on certain inputs. Thank you @Google-Autofuzz.
    Commits
    • 79b7a3c Merge pull request from GHSA-vv2x-vrpj-qqpq
    • 842fcb4 Update for v3.3.0 release
    • 1334134 sanitizer: escape HTML comments
    • c045a8b Merge pull request #581 from mozilla/nit-fixes
    • 491abb0 fix typo s/vnedoring/vendoring/
    • 10b1c5d vendor: add html5lib-1.1.dist-info/REQUESTED
    • cd838c3 Merge pull request #579 from mozilla/validate-convert-entity-code-points
    • 612b808 Update for v3.2.3 release
    • 6879f6a html5lib_shim: validate unicode points for convert_entity
    • 90cb80b Update for v3.2.2 release
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    Dependencies 
    opened by dependabot[bot] 2
  • Default convolution mode introduces edge effects

    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?

    opened by maaleske 3
Releases(v0.2.3)
Owner
colour-science
Colour Science & Digital Imaging
colour-science
Change the image one color channel at a time.

Building-a-Contact-Sheet This hands-on Project is in Python 3 Programming Specialization offered by University of Michigan via Coursera. change the im

Eszter Pai 1 Jan 03, 2022
Wand is a ctypes-based simple ImageMagick binding for Python

Wand Wand is a ctypes-based simple ImageMagick binding for Python, supporting 2.7, 3.3+, and PyPy. All functionalities of MagickWand API are implement

Eric McConville 1.2k Jan 03, 2023
A Python Script to convert Normal PNG Image to Apple iDOT PNG Image.

idot-png-encoder A Python Script to convert Normal PNG Image to Apple iDOT PNG Image (Multi-threaded Decoding PNG). Usage idotpngencoder.py -i inputf

Lrdcq 2 Feb 17, 2022
🎶😤 Generate an image indicating what you are listening to 😳

I'm Listening to This (song that I've sent you an image about detailing its metadata in a nifty way) Few lines describing your project. 📝 Table of Co

Connor B - Viibrant 4 Nov 03, 2021
Python scripts for semi-automated morphometric analysis of atolls from Landsat satellite Imagery.

AtollGeoMorph Python scripts for semi-automated morphometric analysis of atolls from Landsat satellite Imagery. The python scripts included allow user

1 Dec 16, 2022
The following program is used to swap the faces from two images.

Face-Swapping The following program is used to swap the faces from two images. In today's world deep fake technology has become really popular . As a

1 Jan 19, 2022
Hide sensitive information in images

Data-Preserved Script allowing to blur the most sensitive information on images. Prerequisites Before you begin, ensure you have met the following req

2 Dec 01, 2021
A SIXEL encoder/decoder implementation derived from kmiya's sixel

libsixel What is this? This package provides encoder/decoder implementation for DEC SIXEL graphics, and some converter programs. (https://youtu.be/0Sa

Hayaki Saito 2k Jan 09, 2023
Script that organizes the Google Takeout archive into one big chronological folder

Script that organizes the Google Takeout archive into one big chronological folder

Mateusz Soszyński 1.6k Jan 09, 2023
NFT collection generator. Generates layered images

NFT collection generator Generates layered images, whole collections. Provides additional functionality. Repository includes three scripts generate.py

Gleb Gonchar 10 Nov 15, 2022
Convert any binary data to a PNG image file and vice versa.

What is PngBin? The name PngBin comes from an image format file extension PNG (Portable Network Graphics) and the word Binary. An image produced by Pn

Nathan Young 87 Dec 22, 2022
API to help generating QR-code for ZATCA's e-invoice known as Fatoora with any programming language

You can try it @ api-fatoora api-fatoora API to help generating QR-code for ZATCA's e-invoice known as Fatoora with any programming language Disclaime

نافع الهلالي 12 Oct 05, 2022
A simple Streamlit Component to compare images in Streamlit apps. It integrates Knightlab's JuxtaposeJS

streamlit-image-juxtapose A simple Streamlit Component to compare images in Streamlit apps using Knightlab's JuxtaposeJS. The images are saved to the

Robin 30 Dec 31, 2022
Black-white image converter - Black-white photo colorization

Black-white image converter - Black-white photo colorization

1 Jan 02, 2022
A collection of python scripts which help you programatically create PNGs or GIFs

A collection of python scripts which help you programatically create PNGs or GIFs and their Metadata in bulk with custom rarity rates, upload them to OpenSea & list them for sale.

Tom 30 Dec 24, 2022
An esoteric visual language that takes image files as input based on a multi-tape turing machine, designed for compatibility with C.

vizh An esoteric visual language that takes image files as input based on a multi-tape turing machine, designed for compatibility with C. Overview Her

Sy Brand 228 Dec 17, 2022
Using P5.js, Processing and Python to create generative art

Experiments in Generative Art Using Python, Processing, and P5.js Quick Links Daily Sketches March 2021. | Gallery | Repo | Done using P5.js Genuary 2

Ram Narasimhan 33 Jul 06, 2022
display: a browser-based graphics server

display: a browser-based graphics server Installation Quick Start Usage Development A very lightweight display server for Torch. Best used as a remote

Szymon Jakubczak 205 Oct 17, 2022
Validate arbitrary image uploads from incoming data urls while preserving file integrity but removing EXIF and unwanted artifacts and RCE exploit potential

Validate arbitrary base64-encoded image uploads as incoming data urls while preserving image integrity but removing EXIF and unwanted artifacts and mitigating RCE-exploit potential.

A3R0 1 Jan 10, 2022
A simple python script to reveal the contents of a proof of vaccination QR code.

vaxidecoder A simple python script to reveal the contents of a proof of vaccination QR code. It takes a QR code image as input, and returns JSon data.

Hafidh 2 Feb 28, 2022