HDRI - Radiance image processing algorithms for Python.
Performs a simple linear conversion of given array between the old and new ranges.
Parameters: |
|
---|---|
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.])
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']
defaultdict(<function vivification at 0x...>, {u'attribute': 1})
>>> vivified['my']['attribute']
1
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}}
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
Filters given directory for files matching given extensions.
Parameters: |
|
---|---|
Returns: | Filtered files. |
Return type: | list |
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: |
|
---|---|
Returns: | Definition success. |
Return type: | bool |
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 |
Returns given image exif tag value.
Parameters: |
|
---|---|
Returns: | Tag value. |
Return type: | unicode |
Sets given image exif tag value.
Parameters: |
|
---|---|
Returns: | Definition success. |
Return type: | bool |
Computes the exposure value from given image FNumber, Exposure Time and ISO values.
Parameters: |
|
---|---|
Returns: | Image exposure value. |
Return type: | ndarray |
Examples
>>> exposure_value(8, 1, 100)
6.0
Adjusts given array exposure using given \(EV\) exposure value.
Parameters: |
|
---|---|
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. ])
Computes the average luminance from given image FNumber, Exposure Time and ISO values.
Parameters: |
|
---|---|
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
Bases: colour_hdri.utilities.image.Metadata
Defines the base object for storing exif metadata relevant to HDRI / radiance image generation.
Parameters: |
|
---|
Bases: object
Defines the base object for storing an image along its path, pixel data and metadata needed for HDRI / radiance images generation.
Parameters: |
|
---|
Property for self.__data private attribute.
Returns: | self.__data. |
---|---|
Return type: | unicode |
Property for self.__metadata private attribute.
Returns: | self.__metadata. |
---|---|
Return type: | unicode |
Property for self.__path private attribute.
Returns: | self.__path. |
---|---|
Return type: | unicode |
Reads image pixel data at Image.path attribute.
Returns: | Image pixel data. |
---|---|
Return type: | ndarray |
Reads image relevant exif metadata at Image.path attribute.
Returns: | Image relevant exif metadata. |
---|---|
Return type: | Metadata |
Bases: _abcoll.MutableSequence
Defines a convenient stack storing a sequence of images for HDRI / radiance images generation.
Reimplements the MutableSequence.__delitem__() method.
Parameters: | index (int) – Item index. |
---|
Reimplements the MutableSequence.__getattr__() method.
Parameters: | attribute (unicode) – Attribute to retrieve the value. |
---|---|
Returns: | Attribute value. |
Return type: | object |
Reimplements the MutableSequence.__getitem__() method.
Parameters: | index (int) – Item index. |
---|---|
Returns: | Item at given index. |
Return type: | Image |
Reimplements the MutableSequence.__len__() method.
Reimplements the MutableSequence.__getattr__() method.
Parameters: |
|
---|
Reimplements the MutableSequence.__setitem__() method.
Parameters: |
|
---|
Returns a ImageStack instance with given image files.
Parameters: | image_files (array_like) – Image files. |
---|---|
Returns: | |
Return type: | ImageStack |
Reimplements the MutableSequence.insert() method.
Parameters: |
|
---|
Returns the samples for given image stack intensity histograms using Grossberg (2003) method.
Parameters: |
|
---|---|
Returns: | Intensity histograms samples. |
Return type: | ndarray |
Returns given array weighted by a normal distribution function.
Parameters: |
|
---|---|
Returns: | Weighted array. |
Return type: | ndarray |
Examples
>>> normal_distribution_function(np.linspace(0, 1, 10))
array([ 0.00386592, 0.03470859, 0.18002174, 0.53940751, 0.93371212,
0.93371212, 0.53940751, 0.18002174, 0.03470859, 0.00386592])
Returns given array weighted by a hat function.
Parameters: | a (array_like) – Array to apply the weighting function onto. |
---|---|
Returns: | Weighted array. |
Return type: | ndarray |
Examples
>>> hat_function(np.linspace(0, 1, 10))
array([ 0. , 0.95099207, 0.99913557, 0.99999812, 1. ,
1. , 0.99999812, 0.99913557, 0.95099207, 0. ])
Returns given array weighted by Debevec (1997) function.
Parameters: |
|
---|---|
Returns: | Weighted array. |
Return type: | ndarray |
References
[1] | Debevec, P., & Malik, J. (1997). Recovering High Dynamic Range Radiance Maps from Photographs, (August), 1–10. doi:10.1145/258734.258884 |
Examples
>>> weighting_function_Debevec1997(np.linspace(0, 1, 10))
array([ 0. , 0.23273657, 0.48849105, 0.74424552, 1. ,
1. , 0.74424552, 0.48849105, 0.23273657, 0. ])
Generates a HDRI / radiance image from given image stack.
Parameters: |
|
---|---|
Returns: | Radiance image. |
Return type: | ndarray |
Given a set of pixel values observed for several pixels in several images with different exposure times, this function returns the imaging system’s response function \(g\) as well as the log film irradiance values \(lE\) for the observed pixels.
Parameters: |
|
---|---|
Returns: | Camera response functions \(g(z)\) and log film irradiance values \(lE\). |
Return type: | tuple |
Returns the camera response functions for given image stack using Debevec (1997) method.
Image channels are sampled with \(s\) sampling function and the output samples are passed to g_solve().
Parameters: |
|
---|---|
Returns: | Camera response functions \(g(z)\). |
Return type: | ndarray |
Converts given RGB array from camera space to given RGB colourspace.
Parameters: |
|
---|---|
Returns: | RGB colourspace array. |
Return type: | ndarray |
Examples
>>> RGB = np.array([0.80660, 0.81638, 0.65885])
>>> XYZ_to_camera_matrix = np.array([
... [0.47160000, 0.06030000, -0.08300000],
... [-0.77980000, 1.54740000, 0.24800000],
... [-0.14960000, 0.19370000, 0.66510000]])
>>> RGB_to_XYZ_matrix = np.array([
... [0.41238656, 0.35759149, 0.18045049],
... [0.21263682, 0.71518298, 0.07218020],
... [0.01933062, 0.11919716, 0.95037259]])
>>> camera_space_to_RGB(
... RGB,
... XYZ_to_camera_matrix,
... RGB_to_XYZ_matrix)
array([ 0.7564180..., 0.8683192..., 0.6044589...])
Converts given RGB array from camera space to sRGB colourspace.
Parameters: |
|
---|---|
Returns: | sRGB colourspace array. |
Return type: | ndarray |
Examples
>>> RGB = np.array([0.80660, 0.81638, 0.65885])
>>> XYZ_to_camera_matrix = np.array([
... [0.47160000, 0.06030000, -0.08300000],
... [-0.77980000, 1.54740000, 0.24800000],
... [-0.14960000, 0.19370000, 0.66510000]])
>>> camera_space_to_sRGB(RGB, XYZ_to_camera_matrix)
array([ 0.7564180..., 0.8683192..., 0.6044589...])
Plots given HDRI / radiance image as strip of images of varying exposure.
Parameters: |
|
---|---|
Returns: | Definition success. |
Return type: | bool |
Converts given raw files to dng files using given output directory.
Parameters: |
|
---|---|
Returns: | dng files. |
Return type: | list |
Converts given dng files to intermediate tiff files using given output directory.
Parameters: |
|
---|---|
Returns: | Intermediate tiff files. |
Return type: | list |
Performs highlights recovery using Coffin (1997) method from dcraw.
Parameters: |
|
---|---|
Returns: | Highlights recovered RGB colourspace array. |
Return type: | ndarray |
References
[1] | Coffin, D. (2015). dcraw. Retrieved from https://www.cybercom.net/~dcoffin/dcraw/ |
Performs given RGB array tonemapping using the simple method: \(\cfrac{RGB}{RGB + 1}\).
Parameters: | RGB (array_like) – RGB array to perform tonemapping onto. |
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
References
[1] | Wikipedia. (n.d.). Tonemapping - Purpose and methods. Retrieved March 15, 2015, from http://en.wikipedia.org/wiki/Tone_mapping#Purpose_and_methods |
Examples
>>> tonemapping_operator_simple(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.3245382..., 0.2601156..., 0.1911532...],
[ 0.5830618..., 0.3567839..., 0.2808993...]],
[[ 0.8150290..., 0.6831692..., 0.5733340...],
[ 0.8683127..., 0.7746486..., 0.6893211...]]])
Performs given RGB array tonemapping using the normalisation method.
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
References
[2] | (1, 2, 3, 4) Banterle, F., Artusi, A., Debattista, K., & Chalmers, A. (2011). 3.2.1 Simple Mapping Methods. In Advanced High Dynamic Range Imaging (pp. 38–41). A K Peters/CRC Press. ISBN:978-1568817194 |
Examples
>>> tonemapping_operator_normalisation(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.1194995..., 0.0874386..., 0.0587782...],
[ 0.3478115..., 0.1379587..., 0.0971542...]],
[[ 1.0958987..., 0.5362926..., 0.3342109...],
[ 1.6399606..., 0.8549592..., 0.5518371...]]])
Performs given RGB array tonemapping using the gamma and exposure correction method [2].
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
Examples
>>> tonemapping_operator_gamma(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]),
... 1.0, -3.0)
array([[[ 0.0600585..., 0.0439453..., 0.0295410...],
[ 0.1748046..., 0.0693359..., 0.0488282...]],
[[ 0.5507817..., 0.2695323..., 0.1679692...],
[ 0.8242187..., 0.4296892..., 0.2773447...]]])
Performs given RGB array tonemapping using the logarithmic method [2].
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
Examples
>>> tonemapping_operator_logarithmic(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]),
... 1.0, 25)
array([[[ 0.0884587..., 0.0647258..., 0.0435101...],
[ 0.2278221..., 0.0903652..., 0.0636376...]],
[[ 0.4717481..., 0.2308562..., 0.1438667...],
[ 0.5727388..., 0.2985854..., 0.1927232...]]])
Performs given RGB array tonemapping using the exponential method [2].
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
Examples
>>> tonemapping_operator_exponential(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]),
... 1.0, 25)
array([[[ 0.0148082..., 0.0108353..., 0.0072837...],
[ 0.0428668..., 0.0170030..., 0.0119740...]],
[[ 0.1312733..., 0.0642403..., 0.0400338...],
[ 0.1921681..., 0.1001828..., 0.0646634...]]])
Performs given RGB array tonemapping using the logarithmic mapping method.
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
References
[3] | Schlick, C. (1994). Quantization Techniques for Visualization of High Dynamic Range Pictures. Proceedings of the Fifth Eurographics Workshop on Rendering, (Section 5), 7–18. |
Examples
>>> tonemapping_operator_logarithmic_mapping(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.2532896..., 0.1853338..., 0.1245855...],
[ 0.6523381..., 0.2587486..., 0.1822177...]],
[[ 1.3507873..., 0.6610257..., 0.4119430...],
[ 1.6399606..., 0.8549592..., 0.5518371...]]])
Performs given RGB array tonemapping using the exponentiation mapping method [3].
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
Examples
>>> tonemapping_operator_exponentiation_mapping(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.1194995..., 0.0874386..., 0.0587782...],
[ 0.3478115..., 0.1379587..., 0.0971542...]],
[[ 1.0958987..., 0.5362926..., 0.3342109...],
[ 1.6399606..., 0.8549592..., 0.5518371...]]])
Performs given RGB array tonemapping using Schlick (1994) method [2]_[3]_.
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
Examples
>>> tonemapping_operator_Schlick1994(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.1194995..., 0.0874386..., 0.0587782...],
[ 0.3478115..., 0.1379587..., 0.0971542...]],
[[ 1.0958987..., 0.5362926..., 0.3342109...],
[ 1.6399606..., 0.8549592..., 0.5518371...]]])
Performs given RGB array tonemapping using Tumblin (1999) method [2].
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
References
[4] | Tumblin, J., Hodgins, J. K., & Guenter, B. K. (1999). Two methods for display of high contrast images. ACM Transactions on Graphics. doi:10.1145/300776.300783 |
Examples
>>> tonemapping_operator_Tumblin1999(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.0400491..., 0.0293042..., 0.0196989...],
[ 0.1019767..., 0.0404488..., 0.0284851...]],
[[ 0.2490208..., 0.1218616..., 0.0759426...],
[ 0.3408361..., 0.1776878..., 0.1146893...]]])
Performs given RGB array tonemapping using Reinhard (2004) method.
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
References
[5] | Reinhard, E., & Devlin, K. (2005). Dynamic range reduction inspired by photoreceptor physiology. IEEE Transactions on Visualization and Computer Graphics, 11(1), 13–24. doi:10.1109/TVCG.2005.9 |
Examples
>>> tonemapping_operator_Reinhard2004(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]),
... -10)
array([[[ 0.0216792..., 0.0159556..., 0.0107821...],
[ 0.0605893..., 0.0249445..., 0.0176971...]],
[[ 0.1688971..., 0.0904532..., 0.0583583...],
[ 0.2331934..., 0.1368456..., 0.0928316...]]])
Performs given RGB array tonemapping using Reinhard (2004) method.
Parameters: |
|
---|---|
Returns: | Tonemapped RGB array. |
Return type: | ndarray |
References
[6] | Habble, J. (2010). Filmic Tonemapping Operators. Retrieved March 15, 2015, from http://filmicgames.com/archives/75 |
[7] | Habble, J. (2010). Uncharted 2: HDR Lighting. Retrieved March 15, 2015, from http://www.slideshare.net/ozlael/hable-john-uncharted2-hdr-lighting |
Examples
>>> tonemapping_operator_filmic(np.array(
... [[[0.48046875, 0.35156256, 0.23632812],
... [1.39843753, 0.55468757, 0.39062594]],
... [[4.40625388, 2.15625895, 1.34375372],
... [6.59375023, 3.43751395, 2.21875829]]]))
array([[[ 0.4507954..., 0.3619673..., 0.2617269...],
[ 0.7567191..., 0.4933310..., 0.3911730...]],
[[ 0.9725554..., 0.8557374..., 0.7465713...],
[ 1.0158782..., 0.9382937..., 0.8615161...]]])