Overview
slides.com/kmodin/mmg640-colors-images/live#
Isaac Newton's prism and color wheel
Other early contributors:
Thomas Young, Hermann von Helmholtz, James Clerk Maxwell
Quick quiz:
How many colors can be represented in the RBG model?
Think and discuss with your neighbor
Typically three different ways
Quick quiz:
Find web-page for converting between RGB color codes
Quick quiz:
What is the decimal value of #B3 ?
HSV (Hue, Saturation, Value)
Resembles the way colors mix spectrally
HSL (Hue, Saturation, Lightness)
Resembles perceptual color models such as the Natural Color System (NCS)
Quick quiz:
Explore the Matplotlib commands, 'hsv_to_rgb', and 'rgb_to_hsv'
meshgrid command in Numpy is useful
Example: \(f(x,y) = \sin(x y)\) as gray scale image in Numpy
x = np.arange(-3,4); y = np.arange(-3,3)
xx,yy = np.meshgrid(x,y); ff = np.sin(xx*yy)
xx
yy
Quick quiz:
Modify the example to a much higher resolution
Example (cont.):
>> plt.imshow(ff)
Why is it not in gray scale?
Answer: color map used to assign color to each gray value
A colormap is \(n\times 3\) matrix where \(n\) is number of 'gray levels'
Example: (with ff as before)
>> imsave('mycolorfunction.jpg', ff, cmap='viridis')
or
>> imsave('mygrayfunction.jpg', ff, cmap='gray')
Example: (with x,y,ff as before)
>> plt.contour(x,y,ff)
>> plt.colorbar()