Skip to content

Split Image Into Channels

SUMMARY

Split Image Into Channels splits an image into its color channels (B, G, R).

Channel splitting separates a multi-channel image into individual grayscale images, one per channel. Useful for per-channel processing, color-based analysis, and recombining with modified channels via merge_image_from_channels.

Use this Skill when you want to process or analyze individual color channels.

The Skill

python
from telekinesis import pupil

image_channels = pupil.split_image_into_channels(image=image)
channel_images = image_channels.to_list()

API Reference

Example

Input Image

Input image

Original multi-channel image

Channel 1 (Red)

Channel 1

First channel

Channel 2 (Green)

Channel 2

Second channel

Channel 3 (Blue)

Channel 3

Third channel

The Code

python
from telekinesis import pupil
from datatypes import io
import pathlib
from loguru import logger

DATA_DIR = pathlib.Path("path/to/telekinesis-data")

# Load image
filepath = str(DATA_DIR / "images" / "vegetables.jpg")
image = io.load_image(filepath=filepath)
logger.success(f"Loaded image from {filepath}")

# Split image into channels
image_channels = pupil.split_image_into_channels(image=image)
channel_images = image_channels.to_list()
channel_np_list = [img.to_numpy() for img in channel_images]

# Access results
logger.success("Split channels. Number of channels: {}", len(channel_np_list))

The Explanation of the Code

The code begins by importing the necessary modules: pupil for image processing operations, io for data handling, pathlib for path management, and loguru for logging.

python
from telekinesis import pupil
from datatypes import io
import pathlib
from loguru import logger

Next, an image is loaded from a .jpg file using the io.load_image function. The input image must be multi-channel (e.g., BGR or RGB). For BGR input, channels are typically B (index 0), G (index 1), R (index 2).

python
DATA_DIR = pathlib.Path("path/to/telekinesis-data")

# Load image
filepath = str(DATA_DIR / "images" / "vegetables.jpg")
image = io.load_image(filepath=filepath)

The main operation uses the split_image_into_channels Skill from the pupil module. This Skill splits a multi-channel image into individual grayscale images, one per channel.

python
image_channels = pupil.split_image_into_channels(image=image)
channel_images = image_channels.to_list()

Finally, each channel can be converted to a NumPy array using to_numpy() for further processing, visualization, or downstream tasks.

python
channel_np_list = [img.to_numpy() for img in channel_images]
logger.success(f"Split channels. Number of channels: {len(channel_np_list)}")

This operation is particularly useful in robotics and vision pipelines for per-channel processing, color-based analysis, and channel recombining, where separating a multi-channel image into individual channels is required.

How to Tune the Parameters

The split_image_into_channels Skill has no tunable parameters. It requires a multi-channel input image.

Running the Example

Runnable examples are available in the Telekinesis examples repository. Follow the README in that repository to set up the environment. Once set up, you can run this specific example with:

bash
cd telekinesis-examples
python examples/pupil_examples.py --example split_image_into_channels

Where to Use the Skill in a Pipeline

Split Image Into Channels is commonly used in the following pipelines:

  • Per-channel processing - Apply filters or operations to individual channels
  • Color analysis - Analyze channel intensity distributions
  • Channel swapping - Reorder channels before merge
  • Color space conversion - Manual conversion by processing channels

Related skills to build such a pipeline:

  • merge_image_from_channels: Recombine channels after processing
  • convert_image_color_space: Alternative for color space changes

Alternative Skills

Skillvs. Split Image Into Channels
convert_image_color_spaceConverts entire image to new color space. Use split when you need per-channel access or custom processing.

When Not to Use the Skill

Do not use Split Image Into Channels when:

  • You only need a single channel (Convert to grayscale or use indexing)
  • You're working with grayscale images (Already single-channel)
  • You need HSV/LAB channels (Convert color space first, then split)