imagecat.operator.color module

Functions that generate and alter image color.

imagecat.operator.color.colormap(graph, name, inputs)[source]

Convert single-channel layers to RGB layers using a colormap.

Parameters
  • graph (Graph, required) – Graph that owns this task.

  • name (hashable object, required) – Name of the task executing this function.

  • inputs (Named Inputs, required) – Inputs for this operator.

Named Inputs
  • image (imagecat.data.Image, required) – Image with layer to be color mapped.

  • inlayer (str, optional) – image layer to be color mapped. Default: None.

  • outlayer (str, optional) – Name of the output image layer. Default: "C".

  • mapping (Python callable, optional) – Mapping function that accepts a shape (rows, columns, 1) array as input and produces an RGB (rows, columns, 3) shaped array as output. If None (the default), a linear map with a Color Brewer 2 Blue-Red palette will be used.

Returns

image – A copy of the input image with some layers mapped.

Return type

imagecat.data.Image

imagecat.operator.color.dot(graph, name, inputs)[source]

Compute the dot product of a image.data.Layer and a matrix.

This is most commonly used to convert an RGB layer to grayscale, but the operator is capable of converting any depth \(M\) layer to depth \(N\) using an \(M \times N\) matrix. The values in each output channel will be a weighted sum of the input channels, using weights stored in the corresponding matrix column.

Parameters
  • graph (Graph, required) – Graph that owns this task.

  • name (hashable object, required) – Name of the task executing this function.

  • inputs (Named Inputs, required) – Inputs for this operator.

Named Inputs
  • image (imagecat.data.Image, required) – Image containing layer to be converted.

  • inlayer (str, optional) – Layer to be converted. Default: None.

  • outlayer (str, optional) – Output layer. Default: “Y”.

  • outrole (imagecat.data.Role, optional) – Role for the new layer. Defaults to imagecat.data.role.LUMINANCE.

  • matrix (\(M \times N\) numpy.ndarray matrix, optional) – Matrix controlling how much each input channel contributes to each output channel. Defaults to an RGB-to-grayscale matrix. \(M\) must match the depth of the input layer, and \(N\) must match the expected depth of the output role.

Returns

image – Image containing the new layer.

Return type

imagecat.data.Image

imagecat.operator.color.fill(graph, name, inputs)[source]

Generate an image with a single solid-color layer.

Parameters
  • graph (Graph, required) – Graph that owns this task.

  • name (hashable object, required) – Name of the task executing this function.

  • inputs (Named Inputs, required) – Inputs for this operator.

Named Inputs
  • layer (str, optional) – New layer name. Default: “C”.

  • res ((width, height) tuple, optional) – Resolution of the new image. Default: (256, 256).

  • role (imagecat.data.Role, optional) – Semantic role of the new layer. Default: imagecat.data.Role.RGB.

  • values (sequence of values, optional) – Values for the new layer. The number of values must be appropriate for role. Default: [1, 1, 1].

Returns

image – New image with a single solid-color layer.

Return type

imagecat.data.Image