Console/terminal demo of splitting an image into its colour channels with OpenCV, supporting Windows 11 and Ubuntu Linux 24.04. cv2.split separates the B, G and R planes; each plane is a single-channel grayscale image where a bright pixel means that channel is strong there. OpenCV uses BGR channel order rather than the more common RGB, so the planes come back as blue, green, red. One example image ships under data/ (Lena) and the results are saved to model/split/. No GPU is involved. This is the split half of the pair with Image-OpenCV-Merge-Python-1, which shows how to put the channels back together.

 

[Folder Structure]

  • CLAUDE.md / AGENT.md: program specification (identical content).
  • CHANGELOG.md: change log.
  • copyright.txt: copyright notice.
  • data/: the example image Lena.png (the notebook's example).
  • model/split/: the results split_b.png, split_g.png and split_r.png (ship with the Lena examples).
  • tool/tools.py: shared helpers.
  • src/: the demo, the launcher scripts and this document.
  • venv/: Python virtual environment, created by step 1.

[Prerequisites]

  • Operating system: Windows 11 or Ubuntu Linux 24.04.
  • Python 3 and pip.
  • Dependencies are listed in src/requirements.txt and installed by step 1.
  • No GPU required.

[Instructions]

Step 1: create the virtual environment

Delete the old venv/, create a fresh one and install src/requirements.txt. Aborts loudly if pip fails.

 

Windows 11: src\01_venv_create.bat

Ubuntu 24.04: bash src/01_venv_create.sh

 

Step 2: activate the virtual environment

Activate the venv you just created. On Linux, source it so the environment variables apply to the current shell.

 

Windows 11: src\02_venv_activate.bat

Ubuntu 24.04: source src/02_venv_activate.sh

 

Step 3: run the channel-split demo

Separate the image into three single-channel grayscale planes and save them. Extra arguments are forwarded to the Python script.

 

Windows 11: src\03_split.bat

Ubuntu 24.04: bash src/03_split.sh

Your own image:

bash src/03_split.sh --source path/to/image.png

 

Step 4: clear the virtual environment (optional)

Delete the venv/ folder to free disk space when you no longer need it.

 

Windows 11: src\99_venv_clear.bat

Ubuntu 24.04: bash src/99_venv_clear.sh

 

[Python Entry Point]

  • src/split.py: [--source IMG] [--output-dir DIR] [--show].
  • --source: input image, default data/Lena.png.
  • --output-dir: output folder, default model/split/.
  • --show: also open the results in windows.
  • Saves split_b.png, split_g.png and split_r.png, one grayscale plane each.

[References]

 

This SDK is built in AppForAI - AI Dev Tools.

 

Purchase license separately:  USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.