CSE 4227 · Chapter 6 · Deck 14

Colour image processing: RGB, CMY(K), HSI

Every colour model in plain words, the RGB cube drawn properly, step-by-step RGB → CMY and RGB → HSI simulators, and each past theory question answered the way you would write it. Fall 2024 questions are left out.

★ Must study on this page

Colour fundamentals in two minutes

slides 3–8Know in 2 lines
In plain wordsColour is just which wavelengths of light reach your eye. Your eye has three kinds of colour sensors (cones), roughly for red, green and blue, so every colour can be described with three numbers. That is why colour images store three values per pixel.

Slide 3. Colour image processing is about how mathematical models represent and manipulate colour. The key ideas are the physics of light, human vision and colour models, each serving different applications.

Slides 4–6. In 1666 Newton passed sunlight through a prism and got a continuous spectrum of six regions: violet, blue, green, yellow, orange, red. No colour ends abruptly; each blends into the next. Visible light is a narrow band of the electromagnetic spectrum, about 400–700 nm.

violetbluegreenyelloworangered400 nm500 nm600 nm700 nm← ultravioletinfrared →
visible light ≈ 400–700 nm; the six regions blend smoothly (slides 4–6)

Slide 6. The eye has three types of cones, sensitive to red, green and blue. About 6–7 million cones per eye: roughly 65% red-sensitive, 33% green, 2% blue (the blue cones are the most sensitive). This trichromatic system is the basis of most digital colour models.

Slide 7. Colour perception depends on the wavelength composition. CIE (1931) primaries: red = 700 nm, green = 546.1 nm, blue = 435.8 nm. Attributes of colour:

attributemeaning
huethe dominant wavelength: which colour it is (red, green…)
saturationpurity: how much it is diluted with white (high = vivid)
brightness / intensitythe amount of light energy perceived

Slide 8. Colour vision. We see the colour of an object by the light it reflects. White light holds all wavelengths; a red object reflects red and absorbs the rest.

Additive vs subtractive colour

Must studyslides 9–11Came in past papers
In plain wordsScreens make colour by adding light onto black: more light, brighter, until R + G + B = white. Printers make colour by removing light from white paper: each ink soaks up one colour, until C + M + Y absorbs everything = black.
RedGreenBluewhite
additive (light): R + G + B = white; R + G = yellow, G + B = cyan, B + R = magenta
CyanMagentaYellowblack
subtractive (pigment): C + M + Y = black; C + M = blue, M + Y = red, Y + C = green

Slide 9. Colour addition (mixtures of light): primary colours of light (red, green, blue) are additive; red + green + blue gives white.

Slide 10. Colour subtraction (mixtures of pigments): primary colours of pigment (cyan, magenta, yellow) are subtractive; cyan + magenta + yellow gives black. When white light shines on a surface, the pigment absorbs some wavelengths and we see what is not absorbed:

pigmentabsorbsreflectsso it equals
cyanredgreen + bluewhite − red
magentagreenred + bluewhite − green
yellowbluered + greenwhite − blue

Slide 11. Primary and secondary colours:

additive (RGB)subtractive (CMY/CMYK)
works withlight (emitted)pigments / inks (reflected)
primariesred, green, bluecyan, magenta, yellow
start fromblack (no light), then add lightwhite paper, then inks absorb (subtract) light
all three togetherwhiteblack (in practice dark brown, so K is added)
secondariesR+G = yellow, G+B = cyan, B+R = magentaC+M = blue, M+Y = red, Y+C = green
used inmonitors, TVs, cameras, projectorsprinters, presses, packaging
SP22 Final Q7(b)(i)4 marks

Why is RGB called “additive” whereas CMYK is “subtractive”?

RGB builds a colour by adding light of the three primaries on a black (no light) background, as a monitor does: each primary adds energy, and R + G + B at full strength gives white. CMY(K) builds a colour with pigments on white paper: each ink absorbs (subtracts) one primary from the white light, e.g. cyan = white − red, magenta = white − green, yellow = white − blue. Adding more ink removes more light, so C + M + Y gives black (in practice dark brown, so black ink K is added for depth and contrast).

AnswerRGB adds light (all three = white); CMY(K) subtracts light from white (all three = black).

Major colour models and when to use which

Must studyslides 12Came in past papers
In plain wordsA colour model is just a coordinate system for colours. Pick the one that matches the job: light devices use RGB, ink uses CMYK, and when you want to talk about colour the way people do ("which hue?", "how vivid?") use HSI.
modeltypecomponentsapplications
RGBadditive3 channelsdisplays, cameras, image editing
CMY / CMYKsubtractive4 channels (with K)printing, publishing
HSV / HSIperceptualcylindrical coordinatesimage segmentation, computer vision
YIQ / YUVluminance + chrominanceY = brightness, I/Q or U/V = colourtelevision, video compression
CIELABperceptually uniformL* (lightness), a*, b* (colour axes)colour correction, medical / satellite imaging
SP24 Final Q1(d)2 + 3 marks

Which colour model (RGB, CMY, CMYK, HSI) is appropriate for (i) colour printing, (ii) computer displaying? Explain.

(i) Colour printing: CMYK. A printer puts inks on white paper. Inks work by absorbing light, so a subtractive model is needed: cyan, magenta and yellow each remove one primary. Mixing C + M + Y gives only a muddy dark brown, so a separate black (K) ink is added for true black, better contrast and less ink use.

(ii) Computer display: RGB. A monitor emits light. Each pixel has red, green and blue sub-pixels whose light adds up (additive model): (255, 0, 0) is red, (255, 255, 255) is white, (0, 0, 0) is black. RGB also matches the eye's three cone types.

SP25 Final Q1(c)4 marks

Define a colour image. What is the difference between additive and subtractive colour mixing? What is the purpose of colour models in image processing? Which model is appropriate for colour printing and for segmentation?

Colour image: an image whose every pixel holds a colour vector, usually three components (R, G, B), each 8 bits, i.e. 24 bits per pixel.

Additive vs subtractive: additive mixing adds light (R, G, B; all three = white; screens). Subtractive mixing uses pigments that absorb light (C, M, Y; all three = black; printing).

Purpose of colour models: to specify colours in a standard way, as points in a coordinate system, so that hardware (RGB for displays, CMYK for printers) and processing (HSI for describing and analysing colour) can use them.

Printing: CMY/CMYK. Segmentation: HSI/HSV, because hue is kept apart from intensity, so an object can be picked out by its hue even when lighting changes.

RGB model and the colour cube

Must studyslides 13–17Came in past papers
In plain wordsThink of a box. One corner is black (no light). Walk along one edge and red light turns on; along another, green; up, blue. Every colour is one point inside the box, given by how much R, G and B it has. The corner opposite black is white, and the straight line from black to white is every shade of gray.

Slide 13. RGB: type additive; primary components red, green, blue; colours are formed by combining light of the three primaries; each channel ranges 0–255 in 8-bit images.

gray scale (R = G = B)RGBBlack (0,0,0)Red (1,0,0)Green (0,1,0)Blue (0,0,1)YellowCyanMagentaWhite (1,1,1)
RGB colour cube (slide 14), values normalised to [0, 1]; for 8-bit images multiply by 255

Slide 14. The RGB model is based on a Cartesian coordinate system:

Slide 15. How it works. Additive mixing: R + G = yellow, G + B = cyan, B + R = magenta, R + G + B = white, no light = black. Each pixel is defined by three values (R, G, B): (255,0,0) pure red, (0,255,0) pure green, (0,0,255) pure blue, (255,255,0) yellow, (0,255,255) cyan, (255,0,255) magenta, (255,255,255) white, (0,0,0) black.

total colours in a 24-bit RGB image = (28)3 = 224 = 16,777,216

Slide 16. How grayscale is formed: equal intensity in all three channels gives gray: dark gray (50,50,50), medium (128,128,128), light (200,200,200), white (255,255,255), black (0,0,0). These points form the gray axis, the diagonal from black to white.

Slide 17. Applications: displays (monitors, TVs, projectors), cameras (sensors capture R, G, B), image processing (editing and enhancement start in RGB before conversion to HSV, CIELAB…). Limitations: device dependence (colours look different on different screens), not perceptually uniform (equal number changes ≠ equal visible changes), printing issues (printers use CMYK, so RGB must be converted).

Try it, step by step: move the colour around the cube: type any R, G, B and watch where it sits.

SP23 Final Q3(d)3 + 3 + 2 marks

(i) Draw the schematic of the RGB colour cube (Cartesian). (ii) How are colours and gray scale formed in RGB? (iii) How many colours in a standard RGB image?

(i) Draw the cube above: axes R, G, B from the origin; black at (0,0,0); red (1,0,0), green (0,1,0), blue (0,0,1); yellow (1,1,0), cyan (0,1,1), magenta (1,0,1); white (1,1,1); dashed gray-scale diagonal.

(ii) Every colour is a point (R, G, B) on or inside the cube: the three primaries of light are added in those amounts (e.g. (1,1,0) = red + green = yellow). When R = G = B the point lies on the diagonal from black to white, so equal amounts of the three give a shade of gray; (0.5, 0.5, 0.5) is mid-gray.

(iii) 8 bits per channel × 3 channels = 24 bits per pixel, so (28)3 = 224 = 16,777,216 colours.

F23 Final Q1(c) · SP22 Q7(a) · F22 B4(c)4 · 5 · 1 + 4 marks

Draw the RGB colour cube using the Cartesian coordinate system. How are different colours and gray scales formed in the RGB colour model? (SP22: describe the RGB model with a schematic of the cube.)

Same answer as SP23 (i) and (ii). For the 5-mark SP22 version add: RGB is additive; primaries red, green, blue; each channel 0–255 in an 8-bit image; used in monitors, cameras and image editing; 24-bit RGB gives 16,777,216 colours. (F22 Section B is from another examiner's paper.)

CMY and CMYK

slides 18–22On study list
In plain wordsCyan ink is "white minus red". So the amount of cyan you need is just how much red is missing: C = 1 − R. Same for the other two. That is the whole conversion.

Slide 18. CMY: subtractive; primaries cyan, magenta, yellow; colours are formed by overlapping transparent inks that absorb certain wavelengths. Used in printing presses, magazines, packaging and any physical media.

Slide 19. How colours are formed: cyan + magenta = blue; magenta + yellow = red; yellow + cyan = green; cyan + magenta + yellow = dark brown/black (not perfect), so black (K) is added in the CMYK model to improve depth and contrast and to reduce ink usage.

[C M Y]T = [1 1 1]T − [R G B]T    (R, G, B normalised to [0, 1] first)
Slide 20 · worked exampleworked

Convert RGB (98, 35, 146) to CMY.

Step 1 · normalise: R = 98/255 = 0.384, G = 35/255 = 0.137, B = 146/255 = 0.573.

Step 2 · subtract from 1: C = 1 − 0.384 = 0.616, M = 1 − 0.137 = 0.863, Y = 1 − 0.573 = 0.427.

AnswerCMY = (0.616, 0.863, 0.427); in 8-bit form (255 − R, 255 − G, 255 − B) = (157, 220, 109)
TrapSlide 20 prints B = 0.572 and Y = 0.428. 146/255 = 0.5725…, which rounds to 0.573, so Y = 0.427. Either is accepted if you show the working; just keep the same decimals all the way.

Try it, step by step: RGB → CMY, one channel at a time (slide 20's numbers loaded; change them freely).

Slide 20. Applications: printing industry (offset and digital), graphic design (designers convert RGB screen colours to CMYK for accurate print), packaging and branding (consistent colour on physical products).

Slide 21. Challenges: colour shift (screen RGB looks different printed), ink absorption (paper type changes how inks mix), limited gamut (CMYK cannot reproduce all RGB colours, especially bright neon tones). Key insight: RGB is for light-based devices, CMYK for ink-based printing; convert RGB files to CMYK before printing.

Slide 22. Key conversions: RGB ↔ CMYK for digital-to-print workflows; RGB ↔ HSV for isolating hue in object detection; CIELAB ↔ RGB for perceptual uniformity in colour correction.

HSI model and RGB → HSI

slides 23–30Came in past papers
In plain wordsRGB is how machines make colour; HSI is how people describe it. Hue = which colour (an angle round a colour wheel, red at 0°). Saturation = how vivid (0 = gray, 1 = pure). Intensity = how bright (0 = black, 1 = white). Because brightness is kept separate, HSI is great for picking objects by colour.

Slide 23. RGB is useful for hardware and fits how the eye senses colour; RGB is great for colour generation, HSI is great for colour description. HSI uses three measures:

componentmeaningrange
Hue (H)the pure colour (pure yellow, orange or red), an angle from red0°–360°
Saturation (S)how much the pure colour is diluted with white0–1
Intensity (I)achromatic brightness, as in a gray-level image0 (black) – 1 (white)
Red 0°Yellow 60°Green 120°Cyan 180°Blue 240°Magenta 300°HSwhite/gray axis (I)
looking down the gray axis of the RGB cube: primaries 120° apart, secondaries 60° from them (slides 24–25)

Slides 24–25. Look straight down the RGB cube along its gray diagonal and you see a hexagon: each primary is 120° apart (red 0°, green 120°, blue 240°); the secondaries sit 60° from the primaries (yellow 60°, cyan 180°, magenta 300°). The HSI space has a vertical intensity axis; colour points lie on planes perpendicular to it. At an arbitrary colour point: the hue is the angle from a reference point (red); the saturation is the distance from the axis (origin) to the point; the intensity is how far up the axis the plane sits. The plane is often drawn as a circle or a triangle (slides 25–28: slices at I = 0.75 and I = 0.5 of a double cone from black to white).

Conversion from RGB to HSI (slide 29)

Normalise R, G, B to [0, 1] first.
θ = cos⁻¹ { ½[(R − G) + (R − B)] / [(R − G)² + (R − B)(G − B)]½ }
H = θ if B ≤ G;   H = 360° − θ if B > G
S = 1 − 3·min(R, G, B) / (R + G + B)
I = (R + G + B) / 3
Worked · RGB(200, 100, 50) → HSIworked

Step 1 · normalise (divide by 255): R = 200/255 = 0.7843, G = 100/255 = 0.3922, B = 50/255 = 0.1961.

Step 2 · θ

numerator = ½[(R − G) + (R − B)] = ½[(0.3922) + (0.5882)] = 0.4902
denominator = √[(R − G)² + (R − B)(G − B)] = √[0.1538 + (0.5882)(0.1961)] = 0.5188
θ = cos⁻¹(0.4902 / 0.5188) = cos⁻¹(0.9449) = 19.11°

Step 3 · hue: B = 0.1961 ≤ G = 0.3922, so H = θ = 19.11°.

S = 1 − 3·min(R,G,B)/(R + G + B) = 1 − 3 × 0.1961 / 1.3725 = 0.5714
I = (R + G + B)/3 = 1.3725/3 = 0.4575
AnswerRGB(200, 100, 50) → H = 19.11°, S = 0.5714, I = 0.4575

Try it, step by step: RGB → HSI, one quantity at a time (θ top, θ bottom, θ, H, S, I).

Worked · slide 20 colour RGB(98, 35, 146) → HSIpractice

Step 1 · normalise (divide by 255): R = 98/255 = 0.3843, G = 35/255 = 0.1373, B = 146/255 = 0.5725.

Step 2 · θ

numerator = ½[(R − G) + (R − B)] = ½[(0.2471) + (-0.1882)] = 0.0294
denominator = √[(R − G)² + (R − B)(G − B)] = √[0.0610 + (-0.1882)(-0.4353)] = 0.3781
θ = cos⁻¹(0.0294 / 0.3781) = cos⁻¹(0.0778) = 85.54°

Step 3 · hue: B = 0.5725 > G = 0.1373, so H = 360° − θ = 274.46°.

S = 1 − 3·min(R,G,B)/(R + G + B) = 1 − 3 × 0.1373 / 1.0941 = 0.6237
I = (R + G + B)/3 = 1.0941/3 = 0.3647
AnswerRGB(98, 35, 146) → H = 274.46°, S = 0.6237, I = 0.3647

Here B > G, so the hue is measured the long way round: 360° − θ. That puts it between blue (240°) and magenta (300°), which matches a purple colour.

TrapUse the normalised values (÷255) everywhere, including θ. Check B against G before writing H. A gray (R = G = B) has no hue (the bottom of θ is 0) and S = 0.

Conversion from HSI to RGB (slide 30, glance)

sectorformulas
RG: 0° ≤ H < 120°B = I(1 − S);  R = I[1 + S cos H / cos(60° − H)];  G = 3I − (R + B)
GB: 120° ≤ H < 240°H = H − 120°;  R = I(1 − S);  G = I[1 + S cos H / cos(60° − H)];  B = 3I − (R + G)
BR: 240° ≤ H < 360°H = H − 240°;  G = I(1 − S);  B = I[1 + S cos H / cos(60° − H)];  R = 3I − (G + B)
TrapSlide 30 writes the last line as G = 1 − (R + B). That only holds for chromaticity values that add to 1. With I = (R + G + B)/3 the correct line is G = 3I − (R + B) (Gonzalez & Woods). Check: for RGB(200,100,50) it gives back G = 0.392.
F22 Final B5(c) (another examiner's paper)3 + 2 + 3 marks

Explain the HSI colour model with an example. Differences between additive and subtractive colour? How does the combination of cyan, magenta and yellow pigments create different colours?

HSI: describes colour as Hue (angle from red: red 0°, green 120°, blue 240°), Saturation (purity, 0–1) and Intensity (brightness, 0–1). Example: RGB(200, 100, 50) gives H ≈ 19.1° (an orange-red), S ≈ 0.57, I ≈ 0.46.

Additive vs subtractive: see the table in the additive/subtractive section (light vs pigment; all three = white vs black; screens vs printers).

CMY combinations: each pigment removes one primary from white light: cyan + magenta removes red and green, leaving blue; magenta + yellow leaves red; yellow + cyan leaves green; all three remove everything: black.

Other colour theory questions

slides —Know in 2 lines
SP22 Final Q7(b)(ii)4 marks

Basic differences between an RGB image and an indexed colour image? Which is preferred for storage and transmission?

(Not on the Fall 2025 slides; a short answer is enough.)

RGB (true-colour) image: every pixel stores its own three values R, G, B, usually 24 bits per pixel, so it can show any of 16.7 million colours.

Indexed image: every pixel stores only an index (e.g. 8 bits) into a small colour map (palette) that lists the actual RGB colours, e.g. 256 entries.

Storage/transmission: the indexed image is preferred: about 8 bits/pixel plus a small table instead of 24 bits/pixel (GIF uses this). The cost is a limited number of colours.

F21 Final A3(a) (another examiner's paper)8 marks

Inkjet printer and computer: describe the colour model used in a monitor and in a printer. Among red, green and blue, which appears brightest, followed by the others? Justify. Discuss the two major areas of colour image processing.

Monitor: RGB (additive, emits light). Printer: CMYK (subtractive inks on white paper, K added for true black).

Brightest: green, then red, then blue. The eye's overall brightness sensitivity peaks near 555 nm (green), where the red- and green-sensitive cones overlap; very few cones (about 2%) respond to blue, so equal-energy blue looks darkest. (The luminance formula agrees: Y = 0.299R + 0.587G + 0.114B.)

Two major areas (Gonzalez, chapter 6): full-colour processing (images from a full-colour sensor, e.g. a colour camera; process the colour vectors) and pseudo-colour processing (assign colours to gray levels or ranges of intensity to make features easier to see).

Traps and one-minute sheet

slides all
whatformula
RGB → CMYC = 1 − R, M = 1 − G, Y = 1 − B
θcos⁻¹{½[(R−G)+(R−B)] / √[(R−G)² + (R−B)(G−B)]}
Hθ if B ≤ G, else 360° − θ
S1 − 3·min(R,G,B)/(R+G+B)
I(R+G+B)/3