Title: COM366
1TOPIC 9 LIGHT AND COLOUR
RAY TRACING
COM366
2Spectral colours
COM366
3Colour saturation
COM366
4With real colours an additive system is
impossible
Red Green unknown blue
unknown Red Green - blue
COM366
5The human eye
COM366
6Colour sensitivity
Luminous efficiency
COM366
7The theoretical CIE colours
COM366
8A colour combination
Normalised components
Now x y z 1 hence z 1 - x - y and
!
COM366
9COM366
10COM366
11COM366
12COM366
13COM366
14Colour Gamuts
Short Persistence phosphor
Long Persistence phosphor
Red Green Blue
Red Green Blue
x 0.61 0.29 0.15 y
0.35 0.59 0.063
x 0.62 0.21 0.15 y
0.33 0.685 0.063
COM366
15The RGB cube
COM366
16The HSV model
COM366
17RGB to HSV conversion
procedure RGB_to_HSV (r,g,b real h,s,v real)
max lt-- max(r,g,b) min lt-- min(r,g,b) v lt--
max if max ltgt 0 then s lt-- (max -
min)/max else s 0 end if s 0 then
h is undefined else delta lt-- (max -
min) if r max then h lt-- (g - b)/delta
if g max then h lt-- 2 (b-r)/delta
if b max then h lt-- 4 (r - g)/delta h
lt-- h 60 convert to degrees if h lt 0
then h lt-- h 360 end
COM366
18Using colour in MATLAB
Finding the colour depth in your system
get(0,'screendepth')
For an m x n image MATLAB creates
For an RGB image an array of double m x n x 3
For a uint8 image an array of byte m x n x 3
COM366
19Displaying individual colour images
function colourdisplay To demonstrate the
splitting of an image into its primary colours A
imread('monar.jpg') subplot(2,2,1)
imshow(A) title('RGB image') Redimage
A(,,1) subplot(2,2,2) imshow(Redimage) title(
'Red image') Greenimage A(,,2) subplot(2,2,3
) imshow(Greenimage) title('Green
image') Blueimage A(,,3) subplot(2,2,4)
imshow(Blueimage) title('Blue image')
COM366
20COM366
21A1 rgb2hsv(A)
COM366
22Using colour maps
colormap(hsv(16))
COM366
23Inspecting colours in an image
improfile which will reveal the colour
intensity profile along a line defined on the
image. pixval which will interactively record
the location and colour components of each pixel
as you move a cursor across the image. impixel
returns the RGB values for a specified pixel.
COM366
24COM366
25COM366
26Ray Tracing
COM366
27COM366
28COM366
29COM366
30Ray intersection with a bounding sphere
?i (c - s) ?d
COM366
31COM366
32COM366
33COM366