Skip to content

Colour range masks

Keep pixels whose channel values all lie within specified lower and upper bounds.

Try it on your image ↓

VISUAL WALKTHROUGHColour
REFERENCE INPUTObject under uneven lighting

The same scene stays here while the working view changes.

RESULTBinary selection mask

197 of 384 pixels pass the rule. The mask records membership, not the original brightness.

STEP 03 / 03

Write an 8-bit binary mask.

Computed teaching example on a 24 × 16 image. Small kernels and simplified settings keep each change visible; use the image laboratory for native OpenCV.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Select pixels in an HSV interval. Hue uses OpenCV’s 0..179 scale.

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

Select controlled colours or gate pixels by intensity and feature ranges.

How it works

  1. 01Compare every channel with its allowed interval.
  2. 02Combine the channel comparisons.
  3. 03Write an 8-bit binary mask.

mask = AND over channels of lower ≤ value ≤ upper

What to tune

Bounds are inclusive. Choose the colour representation before setting the limits.

Where it breaks down

Lighting changes move colours across fixed bounds. Cyclic hue ranges may need two masks joined together.

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.