290 likes | 305 Views
Explore how colour is represented using mathematical models & the physics and biology behind how we perceive colour. Learn about different colour models like RGB, HSB, CMYK, and techniques like dithering and antialiasing in image processing.
E N D
G6DPMM - Lecture 6 Colour Science & Colour Models
Colour Representation • Colour is represented as a number • Indexed Colour (<24 bit) • Each number is an index into a lookup table (palette)For example (a 2-bit palette): • 0 – black • 1 – white • 2 – red • 3 – green • Implemented in hardware (obsolete) • True colour definition • Colourmapping • True Colour (25 bit) • Each number represents a colour using a mathematical model known as a “colour model”
0.00001nm 10nm 0.03m 0.00003m 0.001nm 1nm 0.3m 5,500km 30m Cosmic Rays Gamma Rays Visible Light X-Rays TV Radio Electricity IR Microwaves UV 700nm 400nm The Physics of Colour • Light is an EM wave in the “visible” part of the spectrum (400-700nm) • Frequency represents colour • Amplitude represents brightness
The Biology of Colour • The human eye • Light is focused onto the retina • The retina contains rods and cones • Rods • Very sensitive – can detect amplitude of light • No mechanism for colour detection • Cones • Less sensitive • Three types – Red, Green & Blue • Each can detect the amplitude of one “primary” colour • Additive colours • Cognition not physics! • Approximately 10-20 million additive colours can be distinguished
Primary / Additive Colours Red Green Blue Red & Green Red & Blue Green & Blue Red, Green & Blue None Red Green Blue Yellow Purple Cyan White Black Primary Additive
RGB Colour Model • 3 Colour Channels • RGB - 1 byte each - 0-255 • Encodes 256 x 256 x 256 = 16,777,216 Colours • True colour (24 bit colour) • Notation is 3 integers (often written as hex) • Examples • 255, 255, 255 (FF FF FF) - White • 255, 0, 0 (FF 00 00) - Red • 255, 0, 255 (FF 00 FF) - Magena • 100, 100, 50 (64 64 32) - Olive
0% 0% 100% 100% HSB Colour Model • Hue, Saturation & Brightness • Hue is an angle (0-360)specifying the position on a colour wheel. • Saturation is a percentage representing the difference from a neutral grey. • Brightness is a percentage representing the continuum from black to white.
Other Colour Models • CMYK • Used mostly for printing, based on cyan, magenta, yellow and black inks used for colour separation. • YIQ & YUV • Used for broadcast TV, an analogue system based upon luminance, chrominance of wave phases. • YCC • Developed by Kodak for Photo CD • Pantone • Colour “catalogue” used by printing industry.
Colour Management • “Perceived” colour is hard to keep exactly constant. • Many factors affect this • Colour model • Monitor • Ambient lighting • Platform (eg Macintosh is typically “brighter” than Windows) • Major problem in multimedia
Image Processing • Processing techniques can create an illusion of colour and detail that is not really present. • Dithering • When reducing colour depth each pixel must be replaced with a corresponding pixel in the target palette. • Antialiasing • When resizing each pixel may be replaced by intermediate colours to avoid “pixelation”
Dithering • Each pixel must be replaced with a corresponding pixel in the target palette. • Adjacent pixels are examined and intermediate colours may be used • Dithering software is built into most bitmap editing/processing software • Algorithms: • Random • Average • Ordered • Floyd-Steinberg
Random Dither • Generate a random (0-255) number for each pixel • If greater than the number pixel=white otherwise black • Crude and “noisy”. • Almost never used
Average Dither • Calculate an average pixel value • If each pixel is above this then white, else black. • Crude and “contrasty”. • Almost never used.
Ordered Dither (pattern) • Divide the image into ordered cells - ie matrices. • Uses matrix arithmetic to compare each pixel with the average “threshold”. • Generate a block of pixels to represent each cell. • Widely used by the printing industry - rare in multimedia.
Floyd-Steinberg Dither • Error diffusion, diffusion, dispersion. • For each pixel the closest colour is found • The difference between this and the original is the error for that pixel. • The error is then “diffused” over adjacent pixels that have not yet been processed. • When these pixels are processed, the error is added to the newly calculated colour. • Widely used in multimedia. • Many minor variants.
Antialiasing • Resampling • Avoids pixellation (“jaggies”) on resizing. • Creates intermediate colour pixels around edges.