colour.recovery.Tree_Otsu2018#
- class colour.recovery.Tree_Otsu2018(*args: Any, **kwargs: Any)[source]#
A sub-class of
colour.recovery.otsu2018.Node
class 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 conversion to dataset, are implemented in this sub-class.
- Parameters:
reflectances (MultiSpectralDistributions) – Reference reflectances of the n reference colours to use for optimisation.
cmfs (MultiSpectralDistributions | None) – Standard observer colour matching functions, default to the CIE 1931 2 Degree Standard Observer.
illuminant (SpectralDistribution | None) – Illuminant spectral distribution, default to CIE Standard Illuminant D65.
Attributes
reflectances
cmfs
illuminant
Methods
__init__()
__str__()
optimise()
to_dataset()
References
[OYH18]
Examples
>>> import os >>> import colour >>> from colour import MSDS_CMFS, SDS_COLOURCHECKERS, SDS_ILLUMINANTS >>> from colour.colorimetry import sds_and_msds_to_msds >>> from colour.utilities import numpy_print_options >>> XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) >>> cmfs = ( ... MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] ... .copy() ... .align(SpectralShape(360, 780, 10)) ... ) >>> illuminant = SDS_ILLUMINANTS["D65"].copy().align(cmfs.shape) >>> reflectances = sds_and_msds_to_msds( ... SDS_COLOURCHECKERS["ColorChecker N Ohta"].values() ... ) >>> node_tree = Tree_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): ... 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...]], SpragueInterpolator, {}, Extrapolator, {'method': 'Constant', 'left': None, 'right': None})
Return a new instance of the
colour.utilities.Node
class.- Parameters:
args – Arguments.
kwargs – Keywords arguments.
reflectances (MultiSpectralDistributions) –
cmfs (MultiSpectralDistributions | None) –
illuminant (SpectralDistribution | None) –
- __init__(reflectances: MultiSpectralDistributions, cmfs: MultiSpectralDistributions | None = None, illuminant: SpectralDistribution | None = None) None [source]#
- Parameters:
reflectances (MultiSpectralDistributions) –
cmfs (MultiSpectralDistributions | None) –
illuminant (SpectralDistribution | None) –
- Return type:
None
Methods
__init__
(reflectances[, cmfs, illuminant])branch_reconstruction_error
()Compute the reconstruction error for all the leaves data connected to the node or its children, i.e. the reconstruction errors summation for all the leaves in the branch.
is_inner
()Return whether the node is an inner node.
is_leaf
()Return whether the node is a leaf node.
is_root
()Return whether the node is a root node.
leaf_reconstruction_error
()Return the reconstruction error of the node data.
minimise
(minimum_cluster_size)Find the best partition for the node that minimises the leaf reconstruction error.
optimise
([iterations, minimum_cluster_size, ...])Optimise the tree by repeatedly performing optimal partitioning of the nodes, creating a tree that minimises the total reconstruction error.
render
([tab_level])Render the current node and its children as a string.
split
(children, axis)Convert the leaf node into an inner node using given children and partition axis.
to_dataset
()Create a
colour.recovery.Dataset_Otsu2018
class instance based on data stored in the tree.walk
([ascendants])Return a generator used to walk into
colour.utilities.Node
trees.Attributes
children
Getter and setter property for the node children.
cmfs
Getter property for the standard observer colour matching functions.
data
Getter property for the node data.
id
Getter property for the node id.
illuminant
Getter property for the illuminant.
leaves
Getter property for the node leaves.
name
Getter and setter property for the name.
parent
Getter and setter property for the node parent.
partition_axis
Getter property for the node partition axis.
reflectances
Getter property for the reference reflectances.
root
Getter property for the node tree.
row
Getter property for the node row for the selector array.
siblings
Getter property for the node siblings.