Skip to content

daft.functions.image_channel#

image_channel #

image_channel(image: Expression) -> Expression

Gets the number of channels in an image.

Parameters:

Name Type Description Default
image Image Expression

image to retrieve the number of channels from.

required

Returns:

Name Type Description
Expression UInt32 Expression

An Expression representing the number of channels in the image.

Example

import daft from daft.functions import image_channel

Create a dataframe with an image column#

df = ... # doctest: +SKIP df = df.with_column("channel", image_channel(df["images"])) # doctest: +SKIP

Source code in daft/functions/image.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
def image_channel(image: Expression) -> Expression:
    """Gets the number of channels in an image.

    Args:
        image (Image Expression): image to retrieve the number of channels from.

    Returns:
        Expression (UInt32 Expression): An Expression representing the number of channels in the image.

    Example:
        >>> import daft
        >>> from daft.functions import image_channel
        >>> # Create a dataframe with an image column
        >>> df = ...  # doctest: +SKIP
        >>> df = df.with_column("channel", image_channel(df["images"]))  # doctest: +SKIP
    """
    return image_attribute(image, "channel")