Colour range masks
Keep pixels whose channel values all lie within specified lower and upper bounds.
The same scene stays here while the working view changes.
Different parts of the object have different intensities because the illumination changes across the image.
Keep intensities in the inclusive interval [100, 170]. This example has one channel; all channels must pass for a colour image.
197 of 384 pixels pass the rule. The mask records membership, not the original brightness.
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
Experiment at pixel level
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.
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
Select a pixel
Select a pixel
When to use it
Select controlled colours or gate pixels by intensity and feature ranges.
How it works
- 01Compare every channel with its allowed interval.
- 02Combine the channel comparisons.
- 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.
Related methods
Histogram equalization
Redistribute grayscale intensities using their cumulative histogram.
CLAHE local contrast
Equalize local histograms while limiting how much a concentrated bin can amplify contrast.
Colour-space conversion
Re-express pixels in a different channel order or colour representation.
White balance
Estimate channel gains or mappings that reduce an image’s illumination colour cast.