Skip to content

Commit

Permalink
Stash current work.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Jul 9, 2024
1 parent 44e5923 commit b407d4c
Show file tree
Hide file tree
Showing 15 changed files with 2,174 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@
"from colour_hdri import (\n",
" ROOT_RESOURCES_EXAMPLES,\n",
" camera_neutral_to_xy,\n",
" camera_space_to_XYZ_matrix,\n",
" convert_dng_files_to_intermediate_files,\n",
" convert_raw_files_to_dng_files,\n",
" filter_files,\n",
" read_dng_files_exif_tags,\n",
" highlights_recovery_LCHab,\n",
" matrix_camera_space_to_XYZ,\n",
" update_exif_tags,\n",
")\n",
"from colour_hdri.models import (\n",
Expand Down Expand Up @@ -193,7 +193,7 @@
" analog_balance,\n",
" )\n",
"\n",
" M_camera_space_to_XYZ = camera_space_to_XYZ_matrix(\n",
" M_camera_space_to_XYZ = matrix_camera_space_to_XYZ(\n",
" xy,\n",
" CCT_calibration_illuminant_1,\n",
" CCT_calibration_illuminant_2,\n",
Expand All @@ -215,7 +215,7 @@
" read_dng_files_exif_tags((DNG_FILES[0],))[0]\n",
")\n",
"\n",
"# In order to avoid artefacts, white balancing should be peformed before\n",
"# In order to avoid artefacts, white balancing should be performed before\n",
"# demosaicing thus we need to pass appropriate gains to *dcraw*.\n",
"WHITE_BALANCE_MULTIPLIERS = colour.algebra.vector_dot(M_CAMERA_SPACE_TO_XYZ, np.ones(3))\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion colour_hdri/examples/examples_merge_from_ldr_files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
" camera_response_functions_Debevec1997,\n",
" filter_files,\n",
" image_stack_to_HDRI,\n",
" weighting_function_Debevec1997,\n",
")\n",
"from colour_hdri.plotting import plot_HDRI_strip\n",
"\n",
Expand Down
123 changes: 70 additions & 53 deletions colour_hdri/examples/examples_merge_from_raw_files_using_rawpy.ipynb

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions colour_hdri/generation/hdri.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from __future__ import annotations

import numpy as np
from colour.constants import EPSILON
from colour.hints import ArrayLike, Callable, NDArrayFloat
from colour.utilities import as_float_array, tsplit, tstack, warning

Expand Down Expand Up @@ -53,7 +54,7 @@ def image_stack_to_HDRI(
Parameters
----------
image_stack
Stack of single channel or multi-channel floating point images. The
Stack of single channel or multichannel floating point images. The
stack is assumed to be representing linear values except if
``camera_response_functions`` argument is provided.
weighting_function
Expand All @@ -71,8 +72,13 @@ def image_stack_to_HDRI(
--------
If the image stack contains images with negative or equal to zero values,
unpredictable results may occur and NaNs might be generated. It is
thus recommended encoding the images in a wider RGB colourspace or clamp
negative values.
thus recommended encoding the images in a wider RGB colourspace. This
definition avoids NaNs creation by ensuring that all values are greater or
equal to current floating point format epsilon. In practical applications
such as HDRI merging with photographic material there should never be a
pixel with a value exactly equal to zero. Ideally, the process should not
be presented by any negative photometric quantity even though RGB
colourspace encodings allows to do so.
References
----------
Expand All @@ -98,14 +104,16 @@ def image_stack_to_HDRI(
f'"{image.path}" image channels contain negative or equal '
f"to zero values, unpredictable results may occur! Please "
f"consider encoding your images in a wider gamut RGB "
f"colourspace or clamp negative values."
f"colourspace."
)

image_data = np.clip(image.data, 0, 1)
image_data = np.clip(image.data, EPSILON, 1)

weights = np.clip(weighting_function(image_data), EPSILON, 1)

weights = weighting_function(image_data)
if i == 0:
weights[image_data >= 0.5] = 1

if i == len(image_stack) - 1:
weights[image_data <= 0.5] = 1

Expand Down
Binary file added colour_hdri/graph/Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added colour_hdri/graph/GraphMergeHDR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added colour_hdri/graph/GraphRawProcessingDNG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added colour_hdri/graph/__init__.py
Empty file.
Loading

0 comments on commit b407d4c

Please sign in to comment.