colour_hdri.utilities Package¶
Sub-Modules¶
Module Contents¶
-
colour_hdri.utilities.
linear_conversion
(a, old_range, new_range)[source]¶ Performs a simple linear conversion of given array between the old and new ranges.
Parameters: - a (array_like) – Array to perform the linear conversion onto.
- old_range (array_like) – Old range.
- new_range (array_like) – New range.
Returns: Return type: ndarray
Examples
>>> a = np.linspace(0, 1, 10) >>> linear_conversion(a, np.array([0, 1]), np.array([1, 10])) array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
-
colour_hdri.utilities.
vivification
()[source]¶ Implements supports for vivification of the underlying dict like data-structure, magical!
Returns: Return type: defaultdict Examples
>>> vivified = vivification() >>> vivified['my']['attribute'] = 1 >>> vivified['my'] # doctest: +ELLIPSIS defaultdict(<function vivification at 0x...>, {u'attribute': 1}) >>> vivified['my']['attribute'] 1
-
colour_hdri.utilities.
vivified_to_dict
(vivified)[source]¶ Converts given vivified data-structure to dictionary.
Parameters: vivified (defaultdict) – Vivified data-structure. Returns: Return type: dict Examples
>>> vivified = vivification() >>> vivified['my']['attribute'] = 1 >>> vivified_to_dict(vivified) {u'my': {u'attribute': 1}}
-
colour_hdri.utilities.
path_exists
(path)[source]¶ Returns if given path exists.
Parameters: path (unicode) – Path to check the existence. Returns: Return type: bool Examples
>>> path_exists(__file__) True >>> path_exists('') False
-
colour_hdri.utilities.
filter_files
(directory, extensions)[source]¶ Filters given directory for files matching given extensions.
Parameters: Returns: Filtered files.
Return type:
-
colour_hdri.utilities.
parse_exif_data
(data)[source]¶ Parses given exif data output from exiftool.
Parameters: data (unicode) – Exif data. Returns: Parsed exif data. Return type: list
Returns given image exif image tags.
Parameters: image (unicode) – Image file. Returns: Exif tags. Return type: defaultdict
Copies given source image file exif tag to given image target.
Parameters: - source (unicode) – Source image file.
- target (unicode) – Target image file.
Returns: Definition success.
Return type:
Updates given images siblings images pairs exif tags.
Parameters: images (list) – Image files to update. Returns: Definition success. Return type: bool
Deletes all given image exif tags.
Parameters: image (unicode) – Image file. Returns: Definition success. Return type: bool
-
colour_hdri.utilities.
read_exif_tag
(image, tag)[source]¶ Returns given image exif tag value.
Parameters: - image (unicode) – Image file.
- tag (unicode) – Tag.
Returns: Tag value.
Return type: unicode
-
colour_hdri.utilities.
write_exif_tag
(image, tag, value)[source]¶ Sets given image exif tag value.
Parameters: - image (unicode) – Image file.
- tag (unicode) – Tag.
- value (unicode) – Value.
Returns: Definition success.
Return type:
-
colour_hdri.utilities.
exposure_value
(f_number, exposure_time, iso)[source]¶ Computes the exposure value from given image FNumber, Exposure Time and ISO values.
Parameters: - f_number (array_like) – Image FNumber.
- exposure_time (array_like) – Image Exposure Time.
- iso (array_like) – Image ISO.
Returns: Image exposure value.
Return type: ndarray
Examples
>>> exposure_value(8, 1, 100) 6.0
-
colour_hdri.utilities.
adjust_exposure
(a, EV)[source]¶ Adjusts given array exposure using given \(EV\) exposure value.
Parameters: - a (array_like) – Array to adjust the exposure.
- EV (numeric) – Exposure adjustment value.
Returns: Exposure adjusted array.
Return type: ndarray
Examples
>>> adjust_exposure(np.array([0.25, 0.5, 0.75, 1]), 1) array([ 0.5, 1. , 1.5, 2. ])
-
colour_hdri.utilities.
average_luminance
(f_number, exposure_time, iso, k=12.5)[source]¶ Computes the average luminance from given image FNumber, Exposure Time and ISO values.
Parameters: - f_number (array_like) – Image FNumber.
- exposure_time (array_like) – Image Exposure Time.
- iso (array_like) – Image ISO.
- k (numeric, optional) – Reflected light calibration constant \(K\).
Returns: Image average luminance.
Return type: ndarray
References
[1] Wikipedia. (n.d.). EV as a measure of luminance and illuminance. Retrieved November 14, 2015, from https://en.wikipedia.org/wiki/Exposure_value#EV_as_a_measure_of_luminance_and_illuminance Examples
>>> average_luminance(8, 1, 100) 0.125
-
class
colour_hdri.utilities.
Metadata
[source]¶ Bases:
colour_hdri.utilities.image.Metadata
Defines the base object for storing exif metadata relevant to HDRI / radiance image generation.
Parameters: - f_number (array_like) – Image FNumber.
- exposure_time (array_like) – Image Exposure Time.
- iso (array_like) – Image ISO.
- black_level (array_like) – Image Black Level.
- white_level (array_like) – Image White Level.
- white_balance_multipliers (array_like) – Image white balance multipliers, usually the As Shot Neutral matrix.
-
class
colour_hdri.utilities.
Image
(path=None, data=None, metadata=None)[source]¶ Bases:
object
Defines the base object for storing an image along its path, pixel data and metadata needed for HDRI / radiance images generation.
Parameters: - path (unicode, optional) – Image path.
- data (array_like, optional) – Image pixel data array.
- metadata (Metadata, optional) – Image exif metadata.
-
path
¶
-
data
¶
-
metadata
¶
-
data
Property for self._data private attribute.
Returns: self._data. Return type: unicode
-
metadata
Property for self._metadata private attribute.
Returns: self._metadata. Return type: unicode
-
path
Property for self._path private attribute.
Returns: self._path. Return type: unicode
-
read_data
()[source] Reads image pixel data at
Image.path
attribute.Returns: Image pixel data. Return type: ndarray
-
read_metadata
()[source] Reads image relevant exif metadata at
Image.path
attribute.Returns: Image relevant exif metadata. Return type: Metadata
-
class
colour_hdri.utilities.
ImageStack
[source]¶ Bases:
collections.abc.MutableSequence
Defines a convenient stack storing a sequence of images for HDRI / radiance images generation.
-
ImageStack
()¶
-
static
from_files
(image_files)[source] Returns a
ImageStack
instance with given image files.Parameters: image_files (array_like) – Image files. Returns: Return type: ImageStack
-