Domains

Creamas includes some utility functions for different artifact domains, i.e. images or language.

TODO: This functionality is currently being developed.

Images

Information

Various image information functions.

creamas.domains.image.image.channel_portion(image, channel)[source]

Estimates the amount of a color relative to other colors.

Parameters
  • image – numpy.ndarray

  • channel – int

Returns

portion of a channel in an image

Return type

float

creamas.domains.image.image.fractal_dimension(image)[source]

Estimates the fractal dimension of an image with box counting. Counts pixels with value 0 as empty and everything else as non-empty. Input image has to be grayscale.

See, e.g Wikipedia.

Parameters

image – numpy.ndarray

Returns

estimation of fractal dimension

Return type

float

creamas.domains.image.image.intensity(image)[source]

Calculates the average intensity of the pixels in an image. Accepts both RGB and grayscale images.

Parameters

image – numpy.ndarray

Returns

image intensity

Return type

float

Features

Various feature implementations. Each feature value takes as an input an artifact, and returns feature’s value for that artifact.

Note

OpenCV has to be installed in order for the ImageComplexityFeature and ImageIntensityFeature classes in this module to work. It is not installed as a default dependency.

Use, e.g. pip install opencv-python

class creamas.domains.image.features.ImageComplexityFeature[source]

Feature that estimates the fractal dimension of an image. The color values must be in range [0, 255] and type int. Returns a float.

Parameters
  • name (str) – Feature’s name

  • domains (list) – A list of all artifact domains (type) that can be evaluated with the feature.

  • rtype – Value type returned by this feature. This can be combined with mappers accepting this type as the input parameter.

extract(artifact)[source]

Extract feature’s value from an artifact.

If artifact with a domain not in domains is used as a parameter, the function should return None.

Note

Dummy implementation, override in a subclass.

Returns

Value extracted from the artifact.

Return type

rtype or None

Raises

NotImplementedError – if not overridden in subclass

class creamas.domains.image.features.ImageRednessFeature[source]

Feature that measures the redness of an image. Returns a float in range [0, 1].

Parameters
  • name (str) – Feature’s name

  • domains (list) – A list of all artifact domains (type) that can be evaluated with the feature.

  • rtype – Value type returned by this feature. This can be combined with mappers accepting this type as the input parameter.

extract(artifact)[source]

Extract feature’s value from an artifact.

If artifact with a domain not in domains is used as a parameter, the function should return None.

Note

Dummy implementation, override in a subclass.

Returns

Value extracted from the artifact.

Return type

rtype or None

Raises

NotImplementedError – if not overridden in subclass

class creamas.domains.image.features.ImageGreennessFeature[source]

Feature that measures the greenness of an image. Returns a float in range [0, 1].

Parameters
  • name (str) – Feature’s name

  • domains (list) – A list of all artifact domains (type) that can be evaluated with the feature.

  • rtype – Value type returned by this feature. This can be combined with mappers accepting this type as the input parameter.

extract(artifact)[source]

Extract feature’s value from an artifact.

If artifact with a domain not in domains is used as a parameter, the function should return None.

Note

Dummy implementation, override in a subclass.

Returns

Value extracted from the artifact.

Return type

rtype or None

Raises

NotImplementedError – if not overridden in subclass

class creamas.domains.image.features.ImageBluenessFeature[source]

Feature that measures the blueness of an image. Returns a float in range [0, 1].

Parameters
  • name (str) – Feature’s name

  • domains (list) – A list of all artifact domains (type) that can be evaluated with the feature.

  • rtype – Value type returned by this feature. This can be combined with mappers accepting this type as the input parameter.

extract(artifact)[source]

Extract feature’s value from an artifact.

If artifact with a domain not in domains is used as a parameter, the function should return None.

Note

Dummy implementation, override in a subclass.

Returns

Value extracted from the artifact.

Return type

rtype or None

Raises

NotImplementedError – if not overridden in subclass

class creamas.domains.image.features.ImageIntensityFeature[source]

Feature that measures the intensity of an image. Returns a float in range [0, 1].

Parameters
  • name (str) – Feature’s name

  • domains (list) – A list of all artifact domains (type) that can be evaluated with the feature.

  • rtype – Value type returned by this feature. This can be combined with mappers accepting this type as the input parameter.

extract(artifact)[source]

Extract feature’s value from an artifact.

If artifact with a domain not in domains is used as a parameter, the function should return None.

Note

Dummy implementation, override in a subclass.

Returns

Value extracted from the artifact.

Return type

rtype or None

Raises

NotImplementedError – if not overridden in subclass

Other domains

Other domains are currently being developed