Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 23, 2024
1 parent d8c5b88 commit 5680e0d
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@
],
"source": [
"HDRI_IMAGE = colour.read_image(\n",
" os.path.join(\n",
" ROOT_RESOURCES, \"Unity_Treasure_Island_White_Balanced.exr\"\n",
" )\n",
" os.path.join(ROOT_RESOURCES, \"Unity_Treasure_Island_White_Balanced.exr\")\n",
")\n",
"\n",
"colour.plotting.plot_image(\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@
"\n",
"logging.basicConfig(level=logging.INFO)\n",
"\n",
"ROOT_RESOURCES = os.path.join(\n",
" ROOT_RESOURCES_EXAMPLES, \"frobisher_001\"\n",
")\n",
"ROOT_RESOURCES = os.path.join(ROOT_RESOURCES_EXAMPLES, \"frobisher_001\")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"import os\n",
"import rawpy\n",
"import colour\n",
"\n",
"# NOTE: Currently requires the latest develop branch.\n",
"import colour_datasets\n",
"\n",
Expand All @@ -85,9 +86,7 @@
"\n",
"logging.basicConfig(level=logging.INFO)\n",
"\n",
"ROOT_RESOURCES = os.path.join(\n",
" ROOT_RESOURCES_EXAMPLES, \"frobisher_001\"\n",
")\n",
"ROOT_RESOURCES = os.path.join(ROOT_RESOURCES_EXAMPLES, \"frobisher_001\")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down Expand Up @@ -126,7 +125,7 @@
" raw = rawpy.imread(path).postprocess(\n",
" gamma=(1, 1), no_auto_bright=True, output_bps=16\n",
" )\n",
" \n",
"\n",
" return colour.utilities.as_float_array(raw) / 65535\n",
"\n",
"\n",
Expand Down Expand Up @@ -249,12 +248,13 @@
"CCT = 6000\n",
"\n",
"SD_ILLUMINANT = colour.sd_CIE_illuminant_D_series(\n",
" colour.temperature.CCT_to_xy_CIE_D(CCT * 1.4388 / 1.4380))\n",
" colour.temperature.CCT_to_xy_CIE_D(CCT * 1.4388 / 1.4380)\n",
")\n",
"\n",
"M_IDT, RGB_w = colour.matrix_idt(SENSITIVITIES, SD_ILLUMINANT)\n",
"\n",
"logging.info(f'\"IDT Matrix\": {M_IDT}')\n",
"logging.info(f'\"White Balance Multipliers\": {RGB_w}')\n"
"logging.info(f'\"White Balance Multipliers\": {RGB_w}')"
]
},
{
Expand Down
32 changes: 8 additions & 24 deletions colour_hdri/examples/examples_global_tonemapping_operators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@
}
],
"source": [
"HDRI_IMAGE = colour.read_image(\n",
" os.path.join(ROOT_RESOURCES, \"HDRMark_small.hdr\")\n",
")\n",
"HDRI_IMAGE = colour.read_image(os.path.join(ROOT_RESOURCES, \"HDRMark_small.hdr\"))\n",
"\n",
"SAMPLES = np.linspace(0, 1, 512)\n",
"D_SAMPLES = np.dstack((SAMPLES, SAMPLES, SAMPLES))\n",
Expand Down Expand Up @@ -276,9 +274,7 @@
" with colour.utilities.suppress_warnings(python_warnings=True):\n",
" plot_tonemapping_operator_image(\n",
" tonemapping_operator_logarithmic(image, q, k),\n",
" np.squeeze(\n",
" tonemapping_operator_logarithmic(D_SAMPLES, q, k)[..., 0]\n",
" ),\n",
" np.squeeze(tonemapping_operator_logarithmic(D_SAMPLES, q, k)[..., 0]),\n",
" title=\"Logarithmic Tonemapping Operator\",\n",
" )\n",
"\n",
Expand Down Expand Up @@ -324,9 +320,7 @@
" with colour.utilities.suppress_warnings(python_warnings=True):\n",
" plot_tonemapping_operator_image(\n",
" tonemapping_operator_exponential(image, q, k),\n",
" np.squeeze(\n",
" tonemapping_operator_exponential(D_SAMPLES, q, k)[..., 0]\n",
" ),\n",
" np.squeeze(tonemapping_operator_exponential(D_SAMPLES, q, k)[..., 0]),\n",
" title=\"Exponential Tonemapping Operator\",\n",
" )\n",
"\n",
Expand Down Expand Up @@ -373,9 +367,7 @@
" plot_tonemapping_operator_image(\n",
" tonemapping_operator_logarithmic_mapping(image, p, q),\n",
" np.squeeze(\n",
" tonemapping_operator_logarithmic_mapping(D_SAMPLES, p, q)[\n",
" ..., 0\n",
" ]\n",
" tonemapping_operator_logarithmic_mapping(D_SAMPLES, p, q)[..., 0]\n",
" ),\n",
" title=\"Logarithmic Mapping Tonemapping Operator\",\n",
" )\n",
Expand Down Expand Up @@ -422,9 +414,7 @@
" with colour.utilities.suppress_warnings(python_warnings=True):\n",
" plot_tonemapping_operator_image(\n",
" tonemapping_operator_exponentiation_mapping(image, p, q),\n",
" np.squeeze(\n",
" tonemapping_operator_exponential(D_SAMPLES, p, q)[..., 0]\n",
" ),\n",
" np.squeeze(tonemapping_operator_exponential(D_SAMPLES, p, q)[..., 0]),\n",
" title=\"Exponentiation Mapping Tonemapping Operator\",\n",
" )\n",
"\n",
Expand Down Expand Up @@ -511,16 +501,12 @@
}
],
"source": [
"def tonemapping_operator_Tumblin1999_interactive(\n",
" image, L_da=20, C_max=100, L_max=100\n",
"):\n",
"def tonemapping_operator_Tumblin1999_interactive(image, L_da=20, C_max=100, L_max=100):\n",
" with colour.utilities.suppress_warnings(python_warnings=True):\n",
" plot_tonemapping_operator_image(\n",
" tonemapping_operator_Tumblin1999(image, L_da, C_max, L_max),\n",
" np.squeeze(\n",
" tonemapping_operator_Tumblin1999(\n",
" D_SAMPLES, L_da, C_max, L_max\n",
" )[..., 0]\n",
" tonemapping_operator_Tumblin1999(D_SAMPLES, L_da, C_max, L_max)[..., 0]\n",
" ),\n",
" title=\"Tumblin (1999) Tonemapping Operator\",\n",
" )\n",
Expand Down Expand Up @@ -567,9 +553,7 @@
"def tonemapping_operator_Reinhard2004_interactive(image, f=0, m=0.3, a=0, c=0):\n",
" plot_tonemapping_operator_image(\n",
" tonemapping_operator_Reinhard2004(image, f, m, a, c),\n",
" np.squeeze(\n",
" tonemapping_operator_Reinhard2004(D_SAMPLES, f, m, a, c)[..., 0]\n",
" ),\n",
" np.squeeze(tonemapping_operator_Reinhard2004(D_SAMPLES, f, m, a, c)[..., 0]),\n",
" title=\"Reinhard (2004) Tonemapping Operator\",\n",
" )\n",
"\n",
Expand Down
10 changes: 3 additions & 7 deletions colour_hdri/examples/examples_merge_from_ldr_files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
"\n",
"logging.basicConfig(level=logging.INFO)\n",
"\n",
"ROOT_RESOURCES = os.path.join(\n",
" ROOT_RESOURCES_EXAMPLES, \"frobisher_001\"\n",
")\n",
"ROOT_RESOURCES = os.path.join(ROOT_RESOURCES_EXAMPLES, \"frobisher_001\")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down Expand Up @@ -117,9 +115,7 @@
"\n",
"for path in RAW_FILES:\n",
" logging.info('Converting \"{0}\" to \"Tiff\" file...'.format(path))\n",
" subprocess.call(\n",
" [\"dcraw\"] + shlex.split('-w -W -H 0 -q 3 -T \"{0}\"'.format(path))\n",
" )\n",
" subprocess.call([\"dcraw\"] + shlex.split('-w -W -H 0 -q 3 -T \"{0}\"'.format(path)))\n",
"\n",
"TIFF_FILES = sorted(glob.glob(\"{0}/*.tiff\".format(ROOT_RESOURCES)))"
]
Expand Down Expand Up @@ -261,7 +257,7 @@
" return paths\n",
"\n",
"\n",
"PATHS = merge_from_ldr_files(TIFF_FILES, ROOT_RESOURCES, CRFS)\n"
"PATHS = merge_from_ldr_files(TIFF_FILES, ROOT_RESOURCES, CRFS)"
]
},
{
Expand Down
14 changes: 3 additions & 11 deletions colour_hdri/examples/examples_merge_from_raw_files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
"logging.basicConfig(level=logging.INFO)\n",
"\n",
"\n",
"ROOT_RESOURCES = os.path.join(\n",
" ROOT_RESOURCES_EXAMPLES, \"frobisher_001\"\n",
")\n",
"ROOT_RESOURCES = os.path.join(ROOT_RESOURCES_EXAMPLES, \"frobisher_001\")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down Expand Up @@ -156,19 +154,13 @@
"DNG_FILES = convert_raw_files_to_dng_files(RAW_FILES, ROOT_RESOURCES)\n",
"\n",
"XYZ_TO_CAMERA_SPACE_MATRIX = colour.utilities.as_float_array(\n",
" [\n",
" float(M_c)\n",
" for M_c in read_exif_tag(DNG_FILES[-2], \"ColorMatrix2\").split()\n",
" ]\n",
" [float(M_c) for M_c in read_exif_tag(DNG_FILES[-2], \"ColorMatrix2\").split()]\n",
").reshape((3, 3))\n",
"\n",
"# In order to avoid artefacts, white balancing should be peformed before\n",
"# demosaicing thus we need to pass appropriate gains to *dcraw*.\n",
"WHITE_BALANCE_MULTIPLIERS = colour.utilities.as_float_array(\n",
" [\n",
" float(M_c)\n",
" for M_c in read_exif_tag(DNG_FILES[-2], \"AsShotNeutral\").split()\n",
" ]\n",
" [float(M_c) for M_c in read_exif_tag(DNG_FILES[-2], \"AsShotNeutral\").split()]\n",
")\n",
"\n",
"WHITE_BALANCE_MULTIPLIERS = 1 / WHITE_BALANCE_MULTIPLIERS\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
"\n",
"logging.basicConfig(level=logging.INFO)\n",
"\n",
"ROOT_RESOURCES = os.path.join(\n",
" ROOT_RESOURCES_EXAMPLES, \"frobisher_001\"\n",
")\n",
"ROOT_RESOURCES = os.path.join(ROOT_RESOURCES_EXAMPLES, \"frobisher_001\")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@
"\n",
"logging.basicConfig(level=logging.INFO)\n",
"\n",
"ROOT_RESOURCES = os.path.join(\n",
" ROOT_RESOURCES_EXAMPLES, \"frobisher_001\"\n",
")\n",
"ROOT_RESOURCES = os.path.join(ROOT_RESOURCES_EXAMPLES, \"frobisher_001\")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down Expand Up @@ -167,10 +165,7 @@
"update_exif_tags(zip(DNG_FILES, INTERMEDIATE_FILES))\n",
"\n",
"XYZ_TO_CAMERA_SPACE_MATRIX = colour.utilities.as_float_array(\n",
" [\n",
" float(M_c)\n",
" for M_c in read_exif_tag(DNG_FILES[-2], \"ColorMatrix2\").split()\n",
" ]\n",
" [float(M_c) for M_c in read_exif_tag(DNG_FILES[-2], \"ColorMatrix2\").split()]\n",
").reshape((3, 3))"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@
"source": [
"HDRI_IMAGE1 = colour.read_image(os.path.join(ROOT_RESOURCES, \"Dots.exr\"))\n",
"\n",
"HDRI_IMAGE2 = colour.read_image(\n",
" os.path.join(ROOT_RESOURCES, \"Grace_Cathedral.hdr\")\n",
")\n",
"HDRI_IMAGE2 = colour.read_image(os.path.join(ROOT_RESOURCES, \"Grace_Cathedral.hdr\"))\n",
"\n",
"Y1 = colour.RGB_luminance(\n",
" HDRI_IMAGE1,\n",
Expand Down Expand Up @@ -255,16 +253,12 @@
],
"source": [
"print(\"Dots - 16 Lights\")\n",
"pprint(\n",
" light_probe_sampling_variance_minimization_Viriyothai2009(HDRI_IMAGE1, 16)\n",
")\n",
"pprint(light_probe_sampling_variance_minimization_Viriyothai2009(HDRI_IMAGE1, 16))\n",
"\n",
"print(\"\\n\")\n",
"\n",
"print(\"Grace Cathedral - 32 Lights\")\n",
"pprint(\n",
" light_probe_sampling_variance_minimization_Viriyothai2009(HDRI_IMAGE2, 32)\n",
")"
"pprint(light_probe_sampling_variance_minimization_Viriyothai2009(HDRI_IMAGE2, 32))"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@
}
],
"source": [
"characterisation_data = colour_hdri.characterise_vignette(\n",
" image, method=\"2D Function\"\n",
")\n",
"characterisation_data = colour_hdri.characterise_vignette(image, method=\"2D Function\")\n",
"\n",
"print(characterisation_data.parameters)\n",
"print(characterisation_data.principal_point)"
Expand Down Expand Up @@ -272,9 +270,7 @@
" image, method=\"Bivariate Spline\"\n",
")\n",
"\n",
"colour.plotting.plot_image(\n",
" colour.cctf_encoding(characterisation_data.parameters)\n",
");"
"colour.plotting.plot_image(colour.cctf_encoding(characterisation_data.parameters));"
]
},
{
Expand Down Expand Up @@ -552,15 +548,11 @@
},
"outputs": [],
"source": [
"figure, axes = colour.plotting.plot_image(\n",
" colour.cctf_encoding(image), standalone=False\n",
")\n",
"figure, axes = colour.plotting.plot_image(colour.cctf_encoding(image), standalone=False)\n",
"\n",
"sampling_coordinates = (\n",
" colour_hdri.distortion.vignette.vignette_sampling_coordinates(\n",
" characterisation_data.principal_point,\n",
" image.shape[1] / image.shape[0],\n",
" )\n",
"sampling_coordinates = colour_hdri.distortion.vignette.vignette_sampling_coordinates(\n",
" characterisation_data.principal_point,\n",
" image.shape[1] / image.shape[0],\n",
")\n",
"\n",
"axes.scatter(\n",
Expand Down Expand Up @@ -627,9 +619,7 @@
}
],
"source": [
"corrected = colour_hdri.correct_vignette(\n",
" image, characterisation_data, method=\"RBF\"\n",
")\n",
"corrected = colour_hdri.correct_vignette(image, characterisation_data, method=\"RBF\")\n",
"\n",
"colour.plotting.plot_image(colour.cctf_encoding(corrected))\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion colour_hdri/exposure/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Define the unit tests for the :mod:`colour_hdri.exposure.common` module."""


import numpy as np
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

Expand Down
1 change: 0 additions & 1 deletion colour_hdri/exposure/tests/test_dsc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Define the unit tests for the :mod:`colour_hdri.exposure.dsc` module."""


import numpy as np
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

Expand Down
1 change: 0 additions & 1 deletion colour_hdri/generation/tests/test_weighting_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
:mod:`colour_hdri.generation.weighting_functions` module.
"""


import numpy as np
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

Expand Down
1 change: 0 additions & 1 deletion colour_hdri/models/tests/test_rgb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Define the unit tests for the :mod:`colour_hdri.models.rgb` module."""


import numpy as np
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
:mod:`colour_hdri.tonemapping.global_operators.operators` module.
"""


import numpy as np
from colour.constants import TOLERANCE_ABSOLUTE_TESTS

Expand Down

0 comments on commit 5680e0d

Please sign in to comment.