colour_hdri.utilities Package¶
Sub-Modules¶
Module Contents¶
-
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:
-
class
colour_hdri.utilities.ExifTag[source]¶ Bases:
colour_hdri.utilities.exif.ExifTagHunt colour appearance model induction factors.
Parameters: - group (unicode, optional) – Exif tag group name.
- name (unicode, optional) – Exif tag name.
- value (object, optional) – Exif tag value.
- identifier (numeric, optional) – Exif tag identifier.
Returns a new instance of the
ExifTagclass.
-
colour_hdri.utilities.parse_exif_string(exif_tag)[source]¶ Parses given exif tag assuming it is a string and return its value.
Parameters: exif_tag (ExifTag) – Exif tag to parse. Returns: Parsed exif tag value. Return type: unicode
-
colour_hdri.utilities.parse_exif_numeric(exif_tag, dtype=<class 'numpy.float64'>)[source]¶ Parses given exif tag assuming it is a numeric type and return its value.
Parameters: Returns: Parsed exif tag value.
Return type: numeric
-
colour_hdri.utilities.parse_exif_fraction(exif_tag, dtype=<class 'numpy.float64'>)[source]¶ Parses given exif tag assuming it is a fraction and return its value.
Parameters: Returns: Parsed exif tag value.
Return type: numeric
-
colour_hdri.utilities.parse_exif_array(exif_tag, dtype=<class 'numpy.float64'>, shape=None)[source]¶ Parses given exif tag assuming it is an array and return its value.
Parameters: Returns: Parsed exif tag value.
Return type: ndarray
-
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.MetadataDefines 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:
objectDefines 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(decoding_cctf=None)[source] Reads image pixel data at
Image.pathattribute.Parameters: decoding_cctf (object, optional) – Decoding colour component transfer function (Decoding CCTF) or electro-optical transfer function (EOTF / EOCF). Returns: Image pixel data. Return type: ndarray
-
read_metadata()[source] Reads image relevant exif metadata at
Image.pathattribute.Returns: Image relevant exif metadata. Return type: Metadata
-
class
colour_hdri.utilities.ImageStack[source]¶ Bases:
collections.abc.MutableSequenceDefines a convenient stack storing a sequence of images for HDRI / radiance images generation.
-
ImageStack()¶
-
static
from_files(image_files, decoding_cctf=None)[source] Returns a
ImageStackinstance with given image files.Parameters: - image_files (array_like) – Image files.
- decoding_cctf (object, optional) – Decoding colour component transfer function (Decoding CCTF) or electro-optical transfer function (EOTF / EOCF).
Returns: Return type:
-
insert(index, value)[source] Reimplements the
MutableSequence.insert()method.Parameters:
-
sort(key=None)[source] Sorts the underlying data structure.
Parameters: key (callable) – Function of one argument that is used to extract a comparison key from each data structure.
-