Color Spaces
Jacky Baltes University of Manitoba Winnipeg, Manitoba Canada R3T 2N2 Email:
[email protected] WWW: avocet.cs.umanitoba.ca
Computer Vision ●
●
Interpreting visual information (images, video) via a computer Image analysis – –
●
Feature extraction: acquire higher level information (edges, shapes, colour) Pattern classification: identifying objects given this information
Applications –
Recognition (faces), image retrieval, medical imaging, robotics, satellite imaging
Imaging hardware ● ●
● ●
● ●
Image acquisition: camera (scanner) Computer system: framegrabber, CMOS sensor – Sampling: continuous signal into fixed rate digital form – Quantization: discretize continuous intensity values Image display Response of a point depends on – intrinsic properties of the point/object – lighting conditions Image is a twodimensional array of intensity values Pixel = picture element
Human vision ● ● ● ● ● ●
Look at a working system Compression Enhancements, restoration The eye and brain are connected by the optic nerve Light: electromagnetic wave 380 – 825 nm Spectral bands: light at specific wave lengths –
red (600 700nm), green (500600nm), blue (400 500nm)
Human vision ●
The eye contains two types of cells – cones (3 types, tristiumulus curves, R (65%) G (33%) B (2%) ) ● sensitive to colour ● daytime vision ● central region of the eye ● high resolution – rods ● only sensitive to brightness ● night vision ● distributed all over the eye ● medium to low resolution – blind spot ● area where the optic nerve enters the eye ● no cells
Spatial frequency resolution ●
Resolution –
●
Spatial frequency – – –
●
Changing signal from Min to Max Depends on distance Cycles per degree to normalize for distance
Limitations – –
●
ability to distinguish two adjacent points
Optical: amount of light than can enter through the lens Neural: smaller than a single cone/rod (spatial resolution)
Spacial resolution depends on average brightness
Brightness adaptation ●
● ●
●
Human vision depends on the average brightness and is limited by the dark threshold and the glare limit Subjective brightness is a logarithmic function Experiments show that we can detect 20 changes in brightness in complex images About 100 brightness levels are needed to produce a complete realistic image (brightness adaptation)
Brightness adaptation ●
False contouring/solarization/polarization – –
●
Mach band effect –
●
bogus lines too few grey levels can not model gradually changing lines Sudden changes in intensity lead to overshooting of the edges, scalloped effect
Brightness adaptation accentuates the edges and aids in separating objects
Brightness adaptation ●
Posterization –
Discretization at 6,4,2, and 1 bit
●
Mach band effect –
Grey levels seem to be increasing, but are stable
Temporal resolution ● ●
Visual information as a function of time Flicker sensitivity –
Limited to 50Hz
Image representation ●
Two dimensional array/matrix of data –
●
Multiband images – –
●
Separate brightness functions I_r, I_g, I_b
Binary image (Black and white) – –
●
I(r,c) = brightness of the image point at r,c
1 bit/pixel Output of edge detection or similar operations
Threshold function
Grey scale images ●
Monochrome – – – – – –
No colour Only contain brightness information 8 bit/pixel > 256 different grey levels Noise margin as compared to human vision Bytes on computers Higher bytes/pixel pictures used in medicine or astronomy
Colour image representation ● ● ●
Additive colour system (colour of light) Primary colours: red, green, blue Secondary colours: magenta (R+B), cyan(G+B), yellow( R+G)
RGB colour space
Subtractive colour system ● ●
Primary colours: magenta, cyan, yellow Secondary colours: red, green, blue
CMY colour space
Colour image representation ●
Characteristics of colour – –
brightness: intensity chromacity: ● ●
●
Tristimulus values –
●
hue: dominant wavelength perceived by the eye saturation: relative purity (amount of white light)
Amount of red (X), green(Y), and blue(Z) necessary to form a particular colour
Trichomatic coefficients (x,y,z) –
x = X/(X+Y+Z), y=Y/(X+Y+Z), z=Z/(X+Y+Z)
Hue Saturation Lightness colour space ● ● ●
Lightness/luminance/luminosity: brightness Hue: colour Saturation: proportion of white (red > pink)
Spherical coordinate transform ● ● ●
Developed by Robin Murphy Decouples brightness from the colour information
Sperical coordinate transform ●
Transform equations
Colour spaces and perception ●
Not perceptually uniform –
●
dependent on the part of the colour space, two different colours will have different perceptual difference, even though they have the same distance
Impossible to define a metric for human perception using these colour spaces
CIE colour spaces ●
●
CIE (Commission Internationale de l’Eclairage) defines international standards Normalized RGB
CIE colour spaces ●
Perceptually uniform Lu*v* and La*b* spaces
YUV colour space ●
British PAL TV standard –
● ● ●
Y – luminance, U,V – colour difference channels
Y= 0.299R+0.587G+0.114B U=0.493(BY), V=0.877(RY) Conversions
YIQ colour space ● ●
Decouple luminance and colour information Used in TV broadcasting – –
●
transmission efficiency compatible with monochrome TVs
Human visual system is more sensitive to changes in intensity than to changes in hue or saturation
YIQ colour space
YDrDB colour space
YcrCb colour space ●
Similar to YUV –
● ● ●
Integer math
Y = 0.299R + 0.587G + 0.114B Cr = 0.713(RY) Cb = 0.564(BY)
Hue Saturation Value (HSV) colour space
HSI colour space
● ● ●
H angle of the vector with the red axis S distance from p to the centre of the triangle I measured w.r.t a line perpendicular to the triangle and going through its centre
HSI colour space
HSI colour space
Image representation ● ●
Efficient data structure for image processing Operations – –
getPixel() various pixel formats ● ● ●
●
RGB565, RGB24, RGB32 HSI YUV422 planar
Other operations – – –
subsampling clipping (regions of interest) zooming
Framebuffer data structure ● ●
Various byte sizes for pixels Make this part of the data structure struct FrameBuffer { unsigned char * buffer; unsigned int width; unsigned int height; unsigned int bytesPerPixel; unsigned int bytesPerLine; };
FrameBuffer routines Boolean getPixel( struct FrameBufferRGB565 * frame, UInt16 x, UInt16 y, struct RawPixel * pixel ) { UInt8 * p; x = clamp( 0, x, frame>width ); y = clamp( 0, y, frame>height ); p = getPixelAddress( frame, x, y ); return convertRGB565ToRawPixel( getRGB565(p), pixel ); }
FrameBuffer data structure ●
Different getPixel/setPixel routines for different type of pixels (RGB565) UInt8 * getPixelAddress( struct FrameBufferRGB565 * frame, UInt16 x, UInt16 y ) { UInt8 * p = NULL; UInt32 rowSkip; UInt32 colSkip; if ( ( x width ) && ( y height ) ) { rowSkip = ( ( UInt32 ) y ) * ( ( UInt32 ) frame>bytesPerLine ); colSkip = ( ( UInt32 ) x ) * ( ( UInt32 ) frame>bytesPerPixel ); p = ( UInt8 * )( ( (UInt32 ) frame>buffer ) + rowSkip + colSkip ); } return p; }
FrameBuffer routines Boolean convertRGB565ToRawPixel( UInt16 colour, struct RawPixel * pixel ) { Boolean result = 0; pixel>red = ( colour >> 8 ) & 0xf8; pixel>green = ( colour >> 3 ) & 0xfc; pixel>blue = ( colour