colour.recovery.NodeTree_Otsu2018¶
- class colour.recovery.NodeTree_Otsu2018(reflectances, cmfs=XYZ_ColourMatchingFunctions(name='CIE 1931 2 Degree Standard Observer', ...), illuminant=SpectralDistribution(name='D65', ...))[source]¶
A sub-class of
colour.recovery.otsu2018.Nodeclass representing the root node of a tree containing information shared with all the nodes, such as the standard observer colour matching functions and the illuminant, if any is used.Global operations involving the entire tree, such as optimisation and reconstruction, are implemented in this sub-class.
- Parameters
reflectances (ndarray, (n, m)) – Reflectances of the n reference colours to use for optimisation.
cmfs (XYZ_ColourMatchingFunctions, optional) – Standard observer colour matching functions.
illuminant (SpectralDistribution, optional) – Illuminant spectral distribution.
Attributes
reflectancescmfsilluminantminimum_cluster_size
Methods
__init__()__str__()msds_to_XYZ()optimise()to_dataset()
References
[]
Examples
>>> import os >>> import colour >>> from colour.characterisation import SDS_COLOURCHECKERS >>> from colour.utilities import numpy_print_options >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> cmfs = ( ... MSDS_CMFS_STANDARD_OBSERVER['CIE 1931 2 Degree Standard Observer']. ... copy().align(SpectralShape(360, 780, 10)) ... ) >>> illuminant = SDS_ILLUMINANTS['D65'].copy().align(cmfs.shape) >>> reflectances = [ ... sd.copy().align(cmfs.shape).values ... for sd in SDS_COLOURCHECKERS['ColorChecker N Ohta'].values() ... ] >>> node_tree = NodeTree_Otsu2018(reflectances, cmfs, illuminant) >>> node_tree.optimise(iterations=2, print_callable=lambda x: x) >>> dataset = node_tree.to_dataset() >>> path = os.path.join(colour.__path__[0], 'recovery', 'tests', ... 'resources', 'ColorChecker_Otsu2018.npz') >>> dataset.write(path) >>> dataset = Dataset_Otsu2018() >>> dataset.read(path) >>> sd = XYZ_to_sd_Otsu2018(XYZ, cmfs, illuminant, dataset) ... >>> with numpy_print_options(suppress=True): ... # Doctests skip for Python 2.x compatibility. ... sd SpectralDistribution([[ 360. , 0.0651341...], [ 370. , 0.0651341...], [ 380. , 0.0651341...], [ 390. , 0.0749684...], [ 400. , 0.0815578...], [ 410. , 0.0776439...], [ 420. , 0.0721897...], [ 430. , 0.0649064...], [ 440. , 0.0567185...], [ 450. , 0.0484685...], [ 460. , 0.0409768...], [ 470. , 0.0358964...], [ 480. , 0.0307857...], [ 490. , 0.0270148...], [ 500. , 0.0273773...], [ 510. , 0.0303157...], [ 520. , 0.0331285...], [ 530. , 0.0363027...], [ 540. , 0.0425987...], [ 550. , 0.0513442...], [ 560. , 0.0579256...], [ 570. , 0.0653850...], [ 580. , 0.0929522...], [ 590. , 0.1600326...], [ 600. , 0.2586159...], [ 610. , 0.3701242...], [ 620. , 0.4702243...], [ 630. , 0.5396261...], [ 640. , 0.5737561...], [ 650. , 0.590848 ...], [ 660. , 0.5935371...], [ 670. , 0.5923295...], [ 680. , 0.5956326...], [ 690. , 0.5982513...], [ 700. , 0.6017904...], [ 710. , 0.6016419...], [ 720. , 0.5996892...], [ 730. , 0.6000018...], [ 740. , 0.5964443...], [ 750. , 0.5868181...], [ 760. , 0.5860973...], [ 770. , 0.5614878...], [ 780. , 0.5289331...]], interpolator=SpragueInterpolator, interpolator_kwargs={}, extrapolator=Extrapolator, extrapolator_kwargs={...})
- __init__(reflectances, cmfs=XYZ_ColourMatchingFunctions(name='CIE 1931 2 Degree Standard Observer', ...), illuminant=SpectralDistribution(name='D65', ...))[source]¶
Methods
PCA()Performs the Principal Component Analysis (PCA) on the colours data of the node and sets the relevant private attributes accordingly.
__init__(reflectances[, cmfs, illuminant])branch_reconstruction_error()Computes the reconstruction error for an entire branch of the tree, starting from the node, i.e. the reconstruction errors summation for all the leaves in the branch.
find_best_partition()Finds the best partition for the node.
is_leaf()Returns whether the node is a leaf.
leaf_reconstruction_error()Reconstructs the reflectance of the CIE XYZ tristimulus values in the colour data of this node using PCA and compares the reconstructed spectrum against the measured spectrum.
msds_to_XYZ(reflectances)Computes the XYZ tristimulus values of a given reflectance.
optimise([iterations, minimum_cluster_size, ...])Optimises the tree by repeatedly performing optimal partitioning of the nodes, creating a tree that minimizes the total reconstruction error.
partition_reconstruction_error(axis)Computes the reconstruction errors summation of the two nodes created by splitting the node with a given partition.
reconstruct(XYZ)Reconstructs the reflectance for the given CIE XYZ tristimulus values.
split(children, partition_axis)Converts the leaf node into a non-leaf node using given children and partition axis.
to_dataset()Creates a
colour.recovery.Dataset_Otsu2018class instance based on data stored in the tree.Attributes
basis_functionsGetter property for the node basis functions.
childrenGetter property for the node children.
cmfsGetter property for the standard observer colour matching functions.
colour_dataGetter property for the node colour data.
idGetter property for the node id.
illuminantGetter property for the illuminant.
leavesGetter property for the node leaves.
meanGetter property for the node mean distribution.
minimum_cluster_sizeGetter property for the minimum cluster size.
partition_axisGetter property for the node partition axis.
reflectancesGetter property for the reflectances.
treeGetter property for the node tree.