Color Channels and Color Spaces
A red inspection part appears blue when its image channels are read in the wrong order.
Color Channels and Color Spaces explained visually
A red inspection part appears blue when its image channels are read in the wrong order. English captions are optional and start off. The complete transcript follows the written lesson.
What you will learn
A red inspection part appears blue when its image channels are read in the wrong order.
Three numbers, one color
You load a photo of a red part from the inspection camera, and suddenly it looks blue on your screen. Did the camera change the part's color? Probably not. First, check how the image software orders its channels. One program may read red, green, and blue. Another may expect blue, green, and red. If we hand the same three numbers to both without converting them, they can display different colors. A known red test object makes that mistake easy to spot.
Choose a useful representation
Think of an R G B pixel as three intensities. We can rearrange that information for different jobs. H S V separates hue, saturation, and value, so a rule about color can sometimes be easier to describe. Other representations separate a brightness-related value from color differences. These are useful views of the data, but changing the color space doesn't fix changing light. Our red part can measure differently in sunlight and shadow.
Watch channel order
What if the task only needs the part's outline? We might convert the image to grayscale. That conversion usually combines all three channels with unequal weights; it isn't just a copy of the red channel. It can simplify shape analysis, but it also removes a distinction we might need to tell red parts from green ones. Keep the original, and check whether the software expects channel values from zero to one or zero to two hundred and fifty-five.
A worked example
Here's the quick test. In an eight-bit R G B image, two hundred and fifty-five, zero, zero means full red. Read the same numbers as B G R, and the display shows blue. The numbers did not change; our interpretation did. Next, we'll make sure resizing an image doesn't move its annotations away from the objects.
Worked example
In an eight-bit RGB illustration, the triplet 255, zero, zero represents full red with no green or blue. Interpreting those same stored values as BGR makes the displayed color blue. The problem is the interpretation, not a change in the underlying three numbers.
Quick check: test your understanding
Try it yourself: Would grayscale be a sensible first step if your task is distinguishing red and green indicator lights? Explain.
Check the reasoning
Not necessarily. Color is central to that task, and the two lights could have similar grayscale intensities. Preserve the color information.
Does HSV make a color threshold reliable under every lighting condition?
No. Illumination, reflections, sensor response, and saturation still affect the measurements.
How would you solve the practice case?
Not necessarily. Color is central to that task, and the two lights could have similar grayscale intensities. Preserve the color information.
What does the worked example show?
In an eight-bit RGB illustration, the triplet 255, zero, zero represents full red with no green or blue. Interpreting those same stored values as BGR makes the displayed color blue. The problem is the interpretation, not a change in the underlying three numbers.
Further reading
Digital Image Processing, 4th edition — Rafael C. Gonzalez and Richard E. Woods.
Original ToolsInVision teaching examples. Editorial approach · Suggest a correction
Accessible referenceLesson 3 transcript287 words · Video transcript · Matches the published narration and captionsOpen transcript
You load a photo of a red part from the inspection camera, and suddenly it looks blue on your screen. Did the camera change the part's color? Probably not. First, check how the image software orders its channels. One program may read red, green, and blue. Another may expect blue, green, and red. If we hand the same three numbers to both without converting them, they can display different colors. A known red test object makes that mistake easy to spot.
Think of an R G B pixel as three intensities. We can rearrange that information for different jobs. H S V separates hue, saturation, and value, so a rule about color can sometimes be easier to describe. Other representations separate a brightness-related value from color differences. These are useful views of the data, but changing the color space doesn't fix changing light. Our red part can measure differently in sunlight and shadow.
What if the task only needs the part's outline? We might convert the image to grayscale. That conversion usually combines all three channels with unequal weights; it isn't just a copy of the red channel. It can simplify shape analysis, but it also removes a distinction we might need to tell red parts from green ones. Keep the original, and check whether the software expects channel values from zero to one or zero to two hundred and fifty-five.
Here's the quick test. In an eight-bit R G B image, two hundred and fifty-five, zero, zero means full red. Read the same numbers as B G R, and the display shows blue. The numbers did not change; our interpretation did. Next, we'll make sure resizing an image doesn't move its annotations away from the objects.