Skip to content

Commit

Permalink
Merge branch 'release/v0.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 2, 2022
2 parents c78eb63 + a2ecf0e commit 4479502
Show file tree
Hide file tree
Showing 24 changed files with 287 additions and 261 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/continuous-integration-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: [3.8]
os: [ubuntu-22.04]
python-version: [3.11]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -31,8 +31,7 @@ jobs:
sudo apt-get --yes install latexmk texlive-full
- name: Install Poetry
run: |
curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
python get-poetry.py
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
shell: bash
- name: Install Package Dependencies
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/continuous-integration-quality-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
strategy:
matrix:
os: [macOS-latest, ubuntu-20.04, windows-latest]
python-version: [3.8, 3.9, '3.10']
os: [macOS-latest, ubuntu-22.04, windows-latest]
python-version: [3.9, '3.10', 3.11]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -22,14 +22,17 @@ jobs:
echo "CI_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" >> $GITHUB_ENV
shell: bash
- name: Set up Python 3.9 for Pre-Commit
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
python get-poetry.py --version 1.1.12
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
shell: bash
- name: Install Package Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ jobs:
strategy:
matrix:
os: [macOS-latest]
python-version: [3.9]
python-version: [3.11]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Environment Variables
run: |
echo "CI_PACKAGE=colour" >> $GITHUB_ENV
echo "CI_PACKAGE=colour_demosaicing" >> $GITHUB_ENV
shell: bash
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Static Type Checking
- name: Install Package Dependencies
run: |
pip install -r requirements.txt
mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --warn-redundant-casts -p $CI_PACKAGE
- name: Static Type Checking
run: |
mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --warn-redundant-casts $CI_PACKAGE
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
*.egg-info
*.pyc
*.pyo
.DS_Store
.coverage
.dmypy.json
.fleet
.idea
.ipynb_checkpoints/
.ipynb_checkpoints
.mypy_cache
.vscode
.sandbox
.vs
.vscode

__pycache__

Expand Down
17 changes: 11 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
- repo: https://github.com/ikamensh/flynt/
rev: '0.76'
rev: '0.77'
hooks:
- id: flynt
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.10.0
hooks:
- id: black
language_version: python3.8
language_version: python3.9
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
language_version: python3.9
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.8"
python: "3.11"

sphinx:
configuration: docs/conf.py
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors
Development & Technical Support
-------------------------------

- **Thomas Mansencal**, *Lead Pipeline Developer @ WetaFX*
- **Thomas Mansencal**, *Technology Supervisor @ Wētā FX*

Project coordination, overall development.

Expand Down
12 changes: 6 additions & 6 deletions colour_demosaicing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
"mosaicing_CFA_Bayer",
]

RESOURCES_DIRECTORY: str = os.path.join(os.path.dirname(__file__), "resources")
EXAMPLES_RESOURCES_DIRECTORY: str = os.path.join(
RESOURCES_DIRECTORY, "colour-demosaicing-examples-datasets"
ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources")
ROOT_RESOURCES_EXAMPLES: str = os.path.join(
ROOT_RESOURCES, "colour-demosaicing-examples-datasets"
)
TESTS_RESOURCES_DIRECTORY: str = os.path.join(
RESOURCES_DIRECTORY, "colour-demosaicing-tests-datasets"
ROOT_RESOURCES_TESTS: str = os.path.join(
ROOT_RESOURCES, "colour-demosaicing-tests-datasets"
)

__application_name__ = "Colour - Demosaicing"

__major_version__ = "0"
__minor_version__ = "2"
__change_version__ = "2"
__change_version__ = "3"
__version__ = ".".join(
(__major_version__, __minor_version__, __change_version__)
)
Expand Down
18 changes: 12 additions & 6 deletions colour_demosaicing/bayer/demosaicing/bilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def demosaicing_CFA_Bayer_bilinear(
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
direct HDRI 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/\
Expand All @@ -69,8 +69,11 @@ def demosaicing_CFA_Bayer_bilinear(
--------
>>> import numpy as np
>>> CFA = np.array(
... [[0.30980393, 0.36078432, 0.30588236, 0.3764706],
... [0.35686275, 0.39607844, 0.36078432, 0.40000001]])
... [
... [0.30980393, 0.36078432, 0.30588236, 0.3764706],
... [0.35686275, 0.39607844, 0.36078432, 0.40000001],
... ]
... )
>>> demosaicing_CFA_Bayer_bilinear(CFA)
array([[[ 0.69705884, 0.17941177, 0.09901961],
[ 0.46176472, 0.4509804 , 0.19803922],
Expand All @@ -82,9 +85,12 @@ def demosaicing_CFA_Bayer_bilinear(
[ 0.15294118, 0.4509804 , 0.59705884],
[ 0.07647059, 0.18431373, 0.90000002]]])
>>> CFA = np.array(
... [[0.3764706, 0.360784320, 0.40784314, 0.3764706],
... [0.35686275, 0.30980393, 0.36078432, 0.29803923]])
>>> demosaicing_CFA_Bayer_bilinear(CFA, 'BGGR')
... [
... [0.3764706, 0.360784320, 0.40784314, 0.3764706],
... [0.35686275, 0.30980393, 0.36078432, 0.29803923],
... ]
... )
>>> demosaicing_CFA_Bayer_bilinear(CFA, "BGGR")
array([[[ 0.07745098, 0.17941177, 0.84705885],
[ 0.15490197, 0.4509804 , 0.5882353 ],
[ 0.15196079, 0.27450981, 0.61176471],
Expand Down
26 changes: 16 additions & 10 deletions colour_demosaicing/bayer/demosaicing/malvar2004.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def demosaicing_CFA_Bayer_Malvar2004(
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
direct HDRI 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/\
Expand All @@ -71,8 +71,11 @@ def demosaicing_CFA_Bayer_Malvar2004(
Examples
--------
>>> CFA = np.array(
... [[0.30980393, 0.36078432, 0.30588236, 0.3764706],
... [0.35686275, 0.39607844, 0.36078432, 0.40000001]])
... [
... [0.30980393, 0.36078432, 0.30588236, 0.3764706],
... [0.35686275, 0.39607844, 0.36078432, 0.40000001],
... ]
... )
>>> demosaicing_CFA_Bayer_Malvar2004(CFA)
array([[[ 0.30980393, 0.31666668, 0.32941177],
[ 0.33039216, 0.36078432, 0.38112746],
Expand All @@ -84,9 +87,12 @@ def demosaicing_CFA_Bayer_Malvar2004(
[ 0.3379902 , 0.36078432, 0.3754902 ],
[ 0.37769609, 0.39558825, 0.40000001]]])
>>> CFA = np.array(
... [[0.3764706, 0.360784320, 0.40784314, 0.3764706],
... [0.35686275, 0.30980393, 0.36078432, 0.29803923]])
>>> demosaicing_CFA_Bayer_Malvar2004(CFA, 'BGGR')
... [
... [0.3764706, 0.360784320, 0.40784314, 0.3764706],
... [0.35686275, 0.30980393, 0.36078432, 0.29803923],
... ]
... )
>>> demosaicing_CFA_Bayer_Malvar2004(CFA, "BGGR")
array([[[ 0.35539217, 0.37058825, 0.3764706 ],
[ 0.34264707, 0.36078432, 0.37450981],
[ 0.36568628, 0.39607844, 0.40784314],
Expand Down Expand Up @@ -157,13 +163,13 @@ def demosaicing_CFA_Bayer_Malvar2004(
del GR_GB, Rg_RB_Bg_BR, Rg_BR_Bg_RB, Rb_BB_Br_RR

# Red rows.
R_r = np.transpose(np.any(R_m == 1, axis=1)[np.newaxis]) * ones(R.shape)
R_r = np.transpose(np.any(R_m == 1, axis=1)[None]) * ones(R.shape)
# Red columns.
R_c = np.any(R_m == 1, axis=0)[np.newaxis] * ones(R.shape)
R_c = np.any(R_m == 1, axis=0)[None] * ones(R.shape)
# Blue rows.
B_r = np.transpose(np.any(B_m == 1, axis=1)[np.newaxis]) * ones(B.shape)
B_r = np.transpose(np.any(B_m == 1, axis=1)[None]) * ones(B.shape)
# Blue columns
B_c = np.any(B_m == 1, axis=0)[np.newaxis] * ones(B.shape)
B_c = np.any(B_m == 1, axis=0)[None] * ones(B.shape)

del R_m, B_m

Expand Down
70 changes: 39 additions & 31 deletions colour_demosaicing/bayer/demosaicing/menon2007.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def demosaicing_CFA_Bayer_Menon2007(
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
direct HDRI 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/\
Expand All @@ -87,8 +87,11 @@ def demosaicing_CFA_Bayer_Menon2007(
Examples
--------
>>> CFA = np.array(
... [[ 0.30980393, 0.36078432, 0.30588236, 0.3764706 ],
... [ 0.35686275, 0.39607844, 0.36078432, 0.40000001]])
... [
... [0.30980393, 0.36078432, 0.30588236, 0.3764706],
... [0.35686275, 0.39607844, 0.36078432, 0.40000001],
... ]
... )
>>> demosaicing_CFA_Bayer_Menon2007(CFA)
array([[[ 0.30980393, 0.35686275, 0.39215687],
[ 0.30980393, 0.36078432, 0.39607844],
Expand All @@ -100,9 +103,12 @@ def demosaicing_CFA_Bayer_Menon2007(
[ 0.30588236, 0.36078432, 0.39019609],
[ 0.32156864, 0.3764706 , 0.40000001]]])
>>> CFA = np.array(
... [[ 0.3764706 , 0.36078432, 0.40784314, 0.3764706 ],
... [ 0.35686275, 0.30980393, 0.36078432, 0.29803923]])
>>> demosaicing_CFA_Bayer_Menon2007(CFA, 'BGGR')
... [
... [0.3764706, 0.36078432, 0.40784314, 0.3764706],
... [0.35686275, 0.30980393, 0.36078432, 0.29803923],
... ]
... )
>>> demosaicing_CFA_Bayer_Menon2007(CFA, "BGGR")
array([[[ 0.30588236, 0.35686275, 0.3764706 ],
[ 0.30980393, 0.36078432, 0.39411766],
[ 0.29607844, 0.36078432, 0.40784314],
Expand Down Expand Up @@ -160,9 +166,9 @@ def demosaicing_CFA_Bayer_Menon2007(
del d_H, d_V, G_H, G_V

# Red rows.
R_r = np.transpose(np.any(R_m == 1, axis=1)[np.newaxis]) * ones(R.shape)
R_r = np.transpose(np.any(R_m == 1, axis=1)[None]) * ones(R.shape)
# Blue rows.
B_r = np.transpose(np.any(B_m == 1, axis=1)[np.newaxis]) * ones(B.shape)
B_r = np.transpose(np.any(B_m == 1, axis=1)[None]) * ones(B.shape)

k_b = as_float_array([0.5, 0, 0.5])

Expand Down Expand Up @@ -248,26 +254,28 @@ def refining_step_Menon2007(
Examples
--------
>>> RGB = np.array(
... [[[0.30588236, 0.35686275, 0.3764706],
... [0.30980393, 0.36078432, 0.39411766],
... [0.29607844, 0.36078432, 0.40784314],
... [0.29803923, 0.37647060, 0.42352942]],
... [[0.30588236, 0.35686275, 0.3764706],
... [0.30980393, 0.36078432, 0.39411766],
... [0.29607844, 0.36078432, 0.40784314],
... [0.29803923, 0.37647060, 0.42352942]]])
... [
... [
... [0.30588236, 0.35686275, 0.3764706],
... [0.30980393, 0.36078432, 0.39411766],
... [0.29607844, 0.36078432, 0.40784314],
... [0.29803923, 0.37647060, 0.42352942],
... ],
... [
... [0.30588236, 0.35686275, 0.3764706],
... [0.30980393, 0.36078432, 0.39411766],
... [0.29607844, 0.36078432, 0.40784314],
... [0.29803923, 0.37647060, 0.42352942],
... ],
... ]
... )
>>> RGB_m = np.array(
... [[[0, 0, 1],
... [0, 1, 0],
... [0, 0, 1],
... [0, 1, 0]],
... [[0, 1, 0],
... [1, 0, 0],
... [0, 1, 0],
... [1, 0, 0]]])
>>> M = np.array(
... [[0, 1, 0, 1],
... [1, 0, 1, 0]])
... [
... [[0, 0, 1], [0, 1, 0], [0, 0, 1], [0, 1, 0]],
... [[0, 1, 0], [1, 0, 0], [0, 1, 0], [1, 0, 0]],
... ]
... )
>>> M = np.array([[0, 1, 0, 1], [1, 0, 1, 0]])
>>> refining_step_Menon2007(RGB, RGB_m, M)
array([[[ 0.30588236, 0.35686275, 0.3764706 ],
[ 0.30980393, 0.36078432, 0.39411765],
Expand Down Expand Up @@ -310,13 +318,13 @@ def refining_step_Menon2007(

# Updating of the red and blue components in the green locations.
# Red rows.
R_r = np.transpose(np.any(R_m == 1, axis=1)[np.newaxis]) * ones(R.shape)
R_r = np.transpose(np.any(R_m == 1, axis=1)[None]) * ones(R.shape)
# Red columns.
R_c = np.any(R_m == 1, axis=0)[np.newaxis] * ones(R.shape)
R_c = np.any(R_m == 1, axis=0)[None] * ones(R.shape)
# Blue rows.
B_r = np.transpose(np.any(B_m == 1, axis=1)[np.newaxis]) * ones(B.shape)
B_r = np.transpose(np.any(B_m == 1, axis=1)[None]) * ones(B.shape)
# Blue columns.
B_c = np.any(B_m == 1, axis=0)[np.newaxis] * ones(B.shape)
B_c = np.any(B_m == 1, axis=0)[None] * ones(B.shape)

R_G = R - G
B_G = B - G
Expand Down
Loading

0 comments on commit 4479502

Please sign in to comment.