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 11, 2024
1 parent 44e5923 commit e3737b5
Show file tree
Hide file tree
Showing 17 changed files with 4,807 additions and 136 deletions.
153 changes: 118 additions & 35 deletions colour_hdri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,34 @@
matrix_XYZ_to_camera_space,
xy_to_camera_neutral,
)
from .network import (
GraphBatchMergeHDRI,
GraphHDRI,
GraphMergeHDRI,
GraphPostMergeHDRI,
GraphRawProcessingCameraSensitivities,
GraphRawProcessingDNG,
InputTransform,
NodeApplyInputTransformCameraSensitivities,
NodeApplyInputTransformDNG,
NodeComputeInputTransformCameraSensitivities,
NodeComputeInputTransformDNG,
NodeConvertRawFileToDNGFile,
NodeCorrectLensAberrationLensFun,
NodeCreateBatches,
NodeCreateImageStack,
NodeDownsample,
NodeMergeImageStack,
NodeNormaliseExposure,
NodeProcessingMetadata,
NodeProcessRawFileRawpy,
NodeReadFileMetadataDNG,
NodeReadImage,
NodeRemoveFile,
NodeWatermark,
NodeWriteImage,
NodeWritePreviewImage,
)
from .process import (
DNG_CONVERTER,
DNG_CONVERTER_ARGUMENTS,
Expand Down Expand Up @@ -114,6 +142,9 @@
copy_exif_tags,
delete_exif_tags,
filter_files,
is_lensfunpy_installed,
is_opencv_installed,
is_rawpy_installed,
parse_exif_array,
parse_exif_data,
parse_exif_fraction,
Expand Down Expand Up @@ -155,63 +186,37 @@ def __getattr__(self, attribute) -> Any:
__status__ = "Production"

__all__ = [
"EXIF_EXECUTABLE",
"EXIFTag",
"Image",
"ImageStack",
"Metadata",
"copy_exif_tags",
"delete_exif_tags",
"filter_files",
"parse_exif_array",
"parse_exif_data",
"parse_exif_fraction",
"parse_exif_number",
"parse_exif_string",
"path_exists",
"read_exif_tag",
"read_exif_tags",
"update_exif_tags",
"vivification",
"vivified_to_dict",
"write_exif_tag",
"absolute_luminance_calibration_Lagarde2016",
"camera_response_functions_Debevec1997",
"g_solve",
"upper_hemisphere_illuminance_weights_Lagarde2016",
]
__all__ += [
"DataVignetteCharacterisation",
"VIGNETTE_CHARACTERISATION_METHODS",
"characterise_vignette",
"VIGNETTE_CORRECTION_METHODS",
"DataVignetteCharacterisation",
"characterise_vignette",
"correct_vignette",
]
__all__ += [
"light_probe_sampling_variance_minimization_Viriyothai2009",
"samples_Grossberg2003",
]
__all__ += [
"adjust_exposure",
"arithmetic_mean_focal_plane_exposure",
"average_illuminance",
"average_luminance",
"exposure_index_values",
"exposure_value_100",
"photometric_exposure_scale_factor_Lagarde2014",
"focal_plane_exposure",
"illuminance_to_exposure_value",
"luminance_to_exposure_value",
"photometric_exposure_scale_factor_Lagarde2014",
"saturation_based_speed_focal_plane_exposure",
]
__all__ += [
"double_sigmoid_anchored_function",
"normal_distribution_function",
"hat_function",
"weighting_function_Debevec1997",
"image_stack_to_HDRI",
]
__all__ += [
"absolute_luminance_calibration_Lagarde2016",
"camera_response_functions_Debevec1997",
"g_solve",
"upper_hemisphere_illuminance_weights_Lagarde2016",
"normal_distribution_function",
"weighting_function_Debevec1997",
]
__all__ += [
"camera_neutral_to_xy",
Expand All @@ -236,6 +241,10 @@ def __getattr__(self, attribute) -> Any:
"highlights_recovery_blend",
"highlights_recovery_LCHab",
]
__all__ += [
"light_probe_sampling_variance_minimization_Viriyothai2009",
"samples_Grossberg2003",
]
__all__ += [
"tonemapping_operator_exponential",
"tonemapping_operator_exponentiation_mapping",
Expand All @@ -249,6 +258,59 @@ def __getattr__(self, attribute) -> Any:
"tonemapping_operator_simple",
"tonemapping_operator_Tumblin1999",
]
__all__ += [
"EXIF_EXECUTABLE",
"EXIFTag",
"Image",
"ImageStack",
"Metadata",
"copy_exif_tags",
"delete_exif_tags",
"filter_files",
"is_rawpy_installed",
"is_lensfunpy_installed",
"is_opencv_installed",
"parse_exif_array",
"parse_exif_data",
"parse_exif_fraction",
"parse_exif_number",
"parse_exif_string",
"path_exists",
"read_exif_tag",
"read_exif_tags",
"update_exif_tags",
"vivification",
"vivified_to_dict",
"write_exif_tag",
]
__all__ += [
"GraphBatchMergeHDRI",
"GraphHDRI",
"GraphMergeHDRI",
"GraphPostMergeHDRI",
"GraphRawProcessingCameraSensitivities",
"GraphRawProcessingDNG",
"InputTransform",
"NodeApplyInputTransformCameraSensitivities",
"NodeApplyInputTransformDNG",
"NodeComputeInputTransformCameraSensitivities",
"NodeComputeInputTransformDNG",
"NodeConvertRawFileToDNGFile",
"NodeCorrectLensAberrationLensFun",
"NodeCreateBatches",
"NodeCreateImageStack",
"NodeDownsample",
"NodeMergeImageStack",
"NodeNormaliseExposure",
"NodeProcessRawFileRawpy",
"NodeProcessingMetadata",
"NodeReadFileMetadataDNG",
"NodeReadImage",
"NodeRemoveFile",
"NodeWatermark",
"NodeWriteImage",
"NodeWritePreviewImage",
]

ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources")
ROOT_RESOURCES_EXAMPLES: str = os.path.join(
Expand Down Expand Up @@ -280,6 +342,27 @@ def __getattr__(self, attribute) -> Any:

colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES["colour-hdri"] = _version # pyright: ignore

if is_rawpy_installed():
import rawpy

colour.utilities.ANCILLARY_RUNTIME_PACKAGES["rawpy"] = rawpy.__version__

del rawpy

if is_lensfunpy_installed():
import lensfunpy

colour.utilities.ANCILLARY_RUNTIME_PACKAGES["lensfunpy"] = lensfunpy.__version__

del lensfunpy

if is_opencv_installed():
import cv2

colour.utilities.ANCILLARY_RUNTIME_PACKAGES["OpenCV"] = cv2.__version__

del cv2

del _version

# TODO: Remove legacy printing support when deemed appropriate.
Expand Down
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
2,154 changes: 2,154 additions & 0 deletions colour_hdri/examples/examples_advanced_processing_with_the_nodegraph.ipynb

Large diffs are not rendered by default.

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
61 changes: 61 additions & 0 deletions colour_hdri/network/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from .nodes import (
InputTransform,
NodeConvertRawFileToDNGFile,
NodeReadImage,
NodeWriteImage,
NodeWritePreviewImage,
NodeWatermark,
NodeProcessingMetadata,
NodeReadFileMetadataDNG,
NodeComputeInputTransformDNG,
NodeComputeInputTransformCameraSensitivities,
NodeProcessRawFileRawpy,
NodeCorrectLensAberrationLensFun,
NodeDownsample,
NodeApplyInputTransformDNG,
NodeApplyInputTransformCameraSensitivities,
NodeRemoveFile,
NodeCreateBatches,
NodeCreateImageStack,
NodeMergeImageStack,
NodeNormaliseExposure,
)
from .graphs import (
GraphRawProcessingDNG,
GraphRawProcessingCameraSensitivities,
GraphMergeHDRI,
GraphPostMergeHDRI,
GraphBatchMergeHDRI,
GraphHDRI,
)

__all__ = [
"InputTransform",
"NodeConvertRawFileToDNGFile",
"NodeReadImage",
"NodeWriteImage",
"NodeWritePreviewImage",
"NodeWatermark",
"NodeProcessingMetadata",
"NodeReadFileMetadataDNG",
"NodeComputeInputTransformDNG",
"NodeComputeInputTransformCameraSensitivities",
"NodeProcessRawFileRawpy",
"NodeCorrectLensAberrationLensFun",
"NodeDownsample",
"NodeApplyInputTransformDNG",
"NodeApplyInputTransformCameraSensitivities",
"NodeRemoveFile",
"NodeCreateBatches",
"NodeCreateImageStack",
"NodeMergeImageStack",
"NodeNormaliseExposure",
]
__all__ += [
"GraphRawProcessingDNG",
"GraphRawProcessingCameraSensitivities",
"GraphMergeHDRI",
"GraphPostMergeHDRI",
"GraphBatchMergeHDRI",
"GraphHDRI",
]
Loading

0 comments on commit e3737b5

Please sign in to comment.