Skip to content

Colour-space conversion

Re-express pixels in a different channel order or colour representation.

Try it on your image ↓

VISUAL WALKTHROUGHColour
REFERENCE INPUTThree-channel colour samples

Colours depend on both channel order and the range assigned to each channel.

RESULTOne-channel luminance values

Weighted luminance converts three values into one. Other colour conversions preserve different properties.

STEP 03 / 03

Write the output channel order and representation.

Illustrative example. The stages explain the method; they are not a live OpenCV execution.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Inspect a colour space channel. Preview normalizes that channel; native values use OpenCV units (8-bit HSV hue is 0..179).

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Convert camera frames to grayscale, select colours in HSV, or adapt data for codecs and models.

How it works

  1. 01Interpret the input channels and their expected numeric range.
  2. 02Apply the selected colour transform.
  3. 03Write the output channel order and representation.

channel meaning + numeric range + transform → new representation

What to tune

The COLOR_* code defines the conversion. Canvas helpers use RGBA; native decoded images use BGR or BGRA.

Where it breaks down

BGR, RGB and RGBA are different conventions. Floating-point conversions may expect normalized ranges; a type change alone does not rescale values.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.