Location:
Color and the Influence of HSV: Why Does Color Segmentation Always Fail Under Changing Illumination?

Color and the Influence of HSV: Why Does Color Segmentation Always Fail Under Changing Illumination?

Color Segmentation · HSV · Illumination Robustness · Machine Vision

2026-11-27 09:51
Color and the Influence of HSV: Why Does Color Segmentation Always Fail Under Changing Illumination? | MindVision

Color and the Influence of HSV: Why Does Color Segmentation Always Fail Under Changing Illumination?

Color Segmentation · HSV · Illumination Robustness · Machine Vision · MindVision

Table of Contents

  1. Where Exactly Does RGB Color Segmentation Get Stuck?
  2. What Does Each of the Three HSV Channels “Manage”?
  3. Why Is HSV More “Stable” Under Illumination?
  4. The “Workflow” of Industrial Color Segmentation: Where HSV Sits in the Chain
  5. Five HSV Pitfalls in Engineering Practice
  6. What HSV Can and Cannot Do: An Honest Boundary
  7. FAQ: Common Questions About HSV Color Segmentation
  8. Conclusion

Introduction

Citable conclusion: HSV is not a “more accurate” color space than RGB; it is a color space more suitable for color segmentation. The H channel carries hue and is largely unaffected by illumination intensity; the S channel describes color purity; the V channel carries brightness independently and can be strategically downweighted or even discarded. The key to understanding HSV is not memorizing the numerical range of H, but understanding the circular topology of the hue wheel and the scaling differences of the H channel across software tools—these two points determine whether thresholds can be reused across platforms and why red always requires two intervals.

In machine vision color segmentation tasks, tuning thresholds directly on RGB images often works in the lab but fails on the production line. The root cause is not that the thresholds are insufficiently fine, but that the three RGB channels are highly coupled: when illumination changes, R, G, and B drift together, and the carefully defined 3D threshold space instantly becomes invalid. The value of HSV is that it separates “what color it is” and “how bright the illumination is” into independent dimensions, turning the segmentation logic from “managing three things at once” into “mainly managing one thing.”

1. Where Exactly Does RGB Color Segmentation Get Stuck?

RGB is a color model oriented toward display devices: it specifies how much each of the red, green, and blue emitters contributes to mix the target color. This definition is extremely efficient for screen display, but it is not friendly for “judging whether a pixel is red.”

The problem lies in channel coupling. The same red object may appear as (R200, G30, B35) under bright light and (R90, G12, B15) in shadow. All three components change together, yet the human eye still judges “it is red.” If RGB is used for threshold segmentation, you must simultaneously define acceptable ranges in the R, G, and B directions, and this 3D region is not a neat cube that simple lower/upper bounds can cover. Worse, light source aging, ambient light fluctuations, and slight changes in surface angle all cause overall drift of RGB components, requiring repeated threshold retuning.

The design starting point of HSV is to break this coupling: it describes color with three independent parameters—Hue (what color it is), Saturation (how pure the color is), and Value (how bright it is). In this way, illumination mainly affects V, while H and S remain relatively stable. You can choose to discard V and rely mainly on H and S for segmentation, fundamentally reducing interference from illumination changes.

2. What Does Each of the Three HSV Channels “Manage”?

A practical way to understand HSV is not to treat it as three parallel numbers, but to understand the question each one answers.

H (Hue) answers “what color this is.” It is expressed as an angle: red at 0°, green at 120°, and blue at 240°, forming a closed hue wheel. This circular topology is the source of all engineering “trouble” in HSV, and also the key that distinguishes it from ordinary 3D coordinates.

S (Saturation) answers “how pure the color is.” The higher the S, the closer the color is to the spectral color itself; the lower the S, the closer the color is to gray or white. In industrial inspection, one practical value of S is filtering out interference from “colorless” objects: white reflections, gray backgrounds, and light-colored dust may have chaotic H values, but their S is usually low, so a lower S bound can exclude them from candidate regions.

V (Value) answers “how bright it is.” V carries illumination information independently. Its role is not “judging color,” but judging whether the pixel has enough light for a reliable color judgment. If a pixel’s V is too low, the H and S values themselves are unreliable—a trap easily overlooked in HSV segmentation, discussed later.

Table 1: Physical Meaning and Segmentation Role of the Three HSV Channels

ChannelQuestion AnsweredValue Range (Concept/OpenCV)Typical Role in Color Segmentation
H (Hue)What color this is0°–360° / 0–180Primary discrimination basis; circular topology, red crosses the seam
S (Saturation)How pure the color is0–100% / 0–255Filters low-saturation interference (white, gray, reflections); auxiliary discrimination
V (Value)How bright it is0–100% / 0–255Carries illumination independently; excludes unreliable pixels that are too dark or overexposed

Table 1 shows that in most industrial color segmentation tasks, H is the primary discrimination channel, S is the filtering channel, and V is the quality gating channel. They are not “three thresholds” of equal weight, but have different roles.

3. Why Is HSV More “Stable” Under Illumination?

HSV illumination robustness is not a vague claim; it has a specific mechanism.

When an object is covered by shadow or illumination intensity changes, the three RGB components change simultaneously proportionally or additively, and the relative relationships among channels are “contaminated” by brightness information. In HSV, brightness information is concentrated in the V channel, and H and S do not vary linearly with illumination intensity under ideal conditions. Experimental observations support this: under low-illumination conditions, HSV shows better applicability than RGB; the stability advantage of HSV under illumination changes is repeatedly mentioned in industrial scenarios.

Shadow discrimination is a direct application of this mechanism. A typical feature of shadow regions is: H and S are similar to the background, but V is significantly lower. Using this “two-same, one-low” pattern, HSV can distinguish shadows from the foreground without destroying target color information. This is also why HSV is widely adopted in video surveillance, outdoor vision, and other scenarios with uncontrollable illumination.

But “stable” is conditional. HSV robustness to illumination is built on the premise that illumination changes do not fundamentally alter hue. If the spectral composition of the light source changes—for example, switching from white light to a sodium lamp, or severe overexposure causing a channel to saturate—H itself will drift, and the HSV advantage no longer holds. In engineering, “HSV is resistant to illumination” must not be understood as “HSV does not require illumination control.”

4. The “Workflow” of Industrial Color Segmentation: Where HSV Sits in the Chain

HSV is not an isolated thresholding step; it plays the role of “color decoupling” in a chain from image acquisition to region output. A typical industrial color segmentation workflow is as follows:

Figure 1: Typical Workflow of HSV-Based Industrial Color Segmentation

Image acquisition (RGB)
↓
Preprocessing: Gaussian blur / white balance correction
↓
Color space conversion: RGB → HSV
↓
Channel selection and thresholding: usually H + S (V as quality gating)
↓
Morphological processing: opening to remove noise / closing to fill holes
↓
Connected component analysis: filter by area and aspect ratio
↓
Output: defect/target region mask

In this workflow, HSV conversion sits after preprocessing and before thresholding, so that subsequent threshold operations are performed in a space where “color and brightness are decoupled.” Gaussian blur in preprocessing deserves separate mention: HSV conversion is very sensitive to small color perturbations, and sensor noise causes sharp jumps in the H channel in flat regions; a slight blur first can significantly improve the cleanliness of threshold segmentation. Morphological processing and connected component filtering are necessary steps to elevate “pixel-level color judgment” to “region-level target judgment”: opening removes isolated noise, closing fills internal breaks in targets, and connected component analysis removes candidates that do not match physical dimensions by area and aspect ratio.

Table 2: Role of Each Stage in the HSV Color Segmentation Workflow

StageWhat It DoesWhat Happens Without It
Preprocessing (blur/white balance)Suppresses noise and stabilizes color referenceH channel jumps; segmentation becomes fragmented
RGB → HSV conversionDecouples color from brightnessRGB channels drift together; thresholds fail
H/S thresholding + V gatingColor discrimination + exclusion of unreliable pixelsPseudo-segmentation in dark or overexposed regions
Morphological processingCleans pixel-level noiseMask has many spurs; connected component statistics distorted
Connected component analysisFilters by physical dimensionsNoise blobs misclassified as targets

Table 2 shows that HSV conversion solves the problem of “color and brightness being mixed together,” but pixel-level segmentation results are inherently noisy and must be converted into usable region information through subsequent morphological and connected component steps. The “accuracy” and “stability” of HSV hold only when the entire chain is correct.

5. Five HSV Pitfalls in Engineering Practice

HSV in theory is clean; HSV in deployment is full of details. The following five issues recur in industrial projects, and understanding them is more important than memorizing threshold ranges.

Pitfall 1: Red Always Requires Two Intervals

The hue wheel is closed: 0° and 360° are geometrically the same point, both corresponding to red. This means red is numerically “cut” into two segments: one near 0° and one near 360° (or 180 in OpenCV). If only one [lower, upper] interval is used, part of red will be missed.

The correct approach is dual-interval thresholding + mask merging: first define the low-hue and high-hue segments separately, generate binary masks for each, then merge with logical OR. This is not a detail that can be bypassed by “tuning parameters”; it is a hard constraint determined by hue wheel topology.

Pitfall 2: OpenCV’s H Range Is 0–180, Not 0–360

The H channel is scaled differently in different software, and this is the most error-prone point when migrating across platforms. OpenCV compresses H to 0–180 (360°/2) for 8-bit images, while S and V remain 0–255. Therefore, the “red seam” in OpenCV appears near 0 and 180, not 0 and 360. The conventional H range for blue in OpenCV is roughly 100–130.

This scaling difference originates from engineering storage constraints, not color theory: an 8-bit unsigned integer can only represent 0–255; OpenCV chooses to divide the 0–360 hue by 2 into 0–180, while some other tools (such as Halcon) choose to map the hue wheel uniformly to 0–255. The same physical red has completely different H values in different tools.

Pitfall 3: At Low Saturation, H Is Meaningless

H reliability presupposes sufficiently high S. When a pixel approaches gray or white, S approaches 0, and hue becomes unstable and physically meaningless: tiny RGB noise can push it to any position on the hue wheel. Therefore, applying a lower S bound before H thresholding is a necessary engineering habit. S is not just “auxiliary discrimination”; it also protects H from noise contamination by low-saturation pixels.

Pitfall 4: When V Is Too Low or Too High, Segmentation Results Are Unreliable

Similarly, V carries illumination information, but “higher is not always better.” When V is too low, sensor noise dominates and the SNR of H and S is insufficient; when V is too high (near saturation), an RGB channel may already be clipped, losing hue information. Therefore, a practical HSV threshold structure is usually H discrimination + lower S bound + a reasonable V window, rather than tuning only H.

Pitfall 5: Halcon’s H Is 0–255, and the Red Seam Position Differs

In Halcon, the H channel output by trans_from_rgb is also an 8-bit image, but the 360° hue wheel is uniformly mapped to 0–255, with 0 and 255 both near red. Therefore, red segmentation in Halcon typically uses two intervals, [0, 20] and [235, 255], corresponding to real angles of about 28° and 338°. If OpenCV thresholds are directly copied to Halcon, or vice versa, the result will certainly be wrong. Thresholds are not “universal knowledge”; they are bound to the color space conventions of the tool.

Table 3: Differences in HSV Conventions Between OpenCV and Halcon

DimensionOpenCVHalcon
H range0–180 (360°/2)0–255 (uniform mapping)
S/V range0–2550–255
Red seam position (H)0 and ~1800 and ~255
Typical red segmentation[0,10] ∪ [170,180][0,20] ∪ [235,255]
Migration noteValues cannot be directly reused across platformsMust recalibrate according to each scale

Table 3 shows that the scaling difference of the H channel is an engineering convention, not a matter of theoretical right or wrong. Thresholds must be recalibrated within the target tool’s coordinate system using histograms or debugging tools, rather than “translated” from another platform’s values.

6. What HSV Can and Cannot Do: An Honest Boundary

The capability boundary of HSV in color segmentation needs to be clearly drawn; otherwise, unrealistic expectations easily arise.

Tasks suitable for HSV include: segmentation of targets with obvious color differences (rust regions, color-variant parts, colored markers), preliminary separation of shadows and objects, and filtering of low-saturation interference. In industrial scenarios, HSV-based rust segmentation has been shown to maintain reliable performance under different illumination and corrosion modes; in copper strip surface inspection, HSV color space segmentation has been used to determine the operating state of slitting units.

Tasks not suitable for HSV alone include: distinguishing white/gray targets from white backgrounds (S approaches 0, H meaningless), scenarios with severe overexposure or drastic spectral changes in illumination (H itself drifts), and defects with similar texture but weak color differences (color is no longer the primary cue). In these cases, HSV needs to be combined with other features (texture, gradient, geometry) or color spaces (Lab is usually better for color difference measurement).

It is worth noting that RGB and HSV are not mutually exclusive. Classification performance using RGB and HSV together can be significantly higher than using either space alone. HSV’s positioning is a decoupling layer in the color segmentation chain, not a universal replacement for all color processing.

FAQ: Common Questions About HSV Color Segmentation

Q: Can H values be directly reused across OpenCV and Halcon?

No. OpenCV’s H is 0–180, while Halcon’s H is 0–255; the same physical red has completely different values in the two tools. Thresholds must be recalibrated within the target tool using histograms or interactive tools.

Q: Why does red always require two threshold intervals?

Because the hue wheel is closed, red crosses the 0° seam and is numerically distributed in two discontinuous intervals. Two threshold intervals are needed to generate masks separately, then merge them.

Q: How should S and V be used in thresholding?

S is usually set with a lower bound to exclude low-saturation interference such as white, gray, and reflections; V is usually set with a reasonable window (neither too low nor too high) to exclude unreliable pixels from dark-region noise and overexposed clipping. H is the primary discrimination channel; S and V are quality gating channels.

Q: Can HSV completely eliminate illumination effects?

No. HSV eliminates the main interference of illumination intensity on color discrimination, but if the spectral composition of the light source changes, or overexposure causes channel saturation, H itself will drift. HSV reduces the strictness of illumination control but does not replace basic illumination stability design.

Q: When is HSV inferior to Lab?

When the core of the task is color difference measurement (how much two colors differ) rather than color classification (which class a pixel belongs to), Lab’s perceptual uniformity usually has an advantage. HSV is more intuitive for “segmentation by hue range,” while Lab is more reasonable for “quantifying color difference magnitude.”

Conclusion

The role of HSV in machine vision can be summarized in one sentence: it does not make color recognition “more accurate”; it makes color recognition “more reasonable” with respect to illumination. RGB delivers color and brightness bound together; HSV separates the two, allowing you to choose to trust only color or only brightness, rather than being forced to simultaneously handle the coupled changes of three channels.

The benefits of this decoupling are real, but the costs are equally real: the hue wheel seam requires dual-interval handling, H scaling differs across tools, and channel reliability decreases in low-saturation and low-brightness regions. Understanding these boundaries has more engineering value than memorizing a set of “standard thresholds.” The stability of color segmentation ultimately comes from the combined effect of illumination control, color space selection, threshold structure design, and post-processing filtering; HSV is a key link, but not the whole story.

#MindVision

Industrial Cameras & Machine Vision for Color Segmentation

MindVision Technology Co., Ltd. is a professional domestic industrial camera manufacturer headquartered in Shenzhen, with production centers and R&D bases in Changsha (Hunan) and Wuxi (Jiangsu), employing nearly 300 people. Its product portfolio covers area-scan cameras, line-scan cameras, thermal imaging cameras, and stereo camera modules, with over 100 patents and software copyrights. The company is ISO9001 certified.

For more information or free selection consulting, please visit MindVision's official website or contact the sales team.

© MindVision — Industrial Camera Solutions for Color Segmentation & Machine Vision

We’ll be glad to help you

  • Full Name

  • Company Name

  • E-mail*

  • Country / Region

  • Your Needs / Application*

  • Verification code