Lecture 2 Color Representation and Quantization

Yao Wang Polytechnic Institute of NYU, Brooklyn, NY 11201

With contributions from Zhu Liu, AT&T Labs Most figures from Gonzalez/Woods: Digital Image Processing Lecture Outline

• Color perception and representation – Human ppperception of color – Trichromatic color mixing theory – Different color representations • ClColor image dildisplay – True color image – images • Pseudo color images • Quantization Fundamentals – Uniform, non-uniform, dithering • Color quantization

Yao Wang, NYU-Poly EL5123: color and quantization 2 Light is part of the EM wave

Yao Wang, NYU-Poly EL5123: color and quantization 3 Illuminating and Reflecting Light

• Illuminating sources (primary light): – emit light (e.g. the sun, light bulb, TV monitors) – perceived color depends on the emitted freq. – follow additive rule • R+G+B=White • Reflecting sources (secondary light): – reflect an incoming light (e.g. the color dye, matte surface, cloth) – perceived color depends on reflected freq (=emitted freq-absorbed freq.) – follow subtractive rule • R+G+B=Black

Yao Wang, NYU-Poly EL5123: color and quantization 4 Eye vs. Camera

Camera components Eye components Lens Lens, cornea Shutter Iris, pupil Film RtiRetina Cable to transfer images Optic nerve send the info to the brain Yao Wang, NYU-Poly EL5123: color and quantization 5 Human Perception of Color

• Retina contains receptors – Cones • Day vision, can perceive color tone • Red, green, and blue cones – Rods • Night vision, perceive brightness only • Color sensation – Luminance (brightness) – Chrominance From http://www.macula.org/anatomy/ • Hue (color tone) retinaframe.html • Saturation (color purity)

Yao Wang, NYU-Poly EL5123: color and quantization 6 Frequency Responses of Cones and the Luminous Efficiency Function

Ci  C()ai ()d, i  r, g,b, y

Yao Wang, NYU-Poly EL5123: color and quantization 7 Tri-chromatic Color Mixing

• Tri-chromatic color mixing theory – Any color can be obtained by mixing three primary colors with a right proportion • Primary colors for illuminating sources: – Red, Green, Blue (RGB) – Color monitor works by exciting red, green, blue phosphors using separate electronic guns – follow additive rule: R+G+B=White • Primary colors for reflecting sources (also known as secondary colors): – Cyan, Magenta, Yellow (CMY) – Color printer works by using cyan, magenta, yellow and black (CMYK) dyes – follow subtractive rule: R+G+B=Black

Yao Wang, NYU-Poly EL5123: color and quantization 8 RGB vs CMY

Magenta = Red + Blue Magenta = White - Green Cyan = Blue + Green Cyan = White - Red Yellow = Green + Red Yellow = White - Blue

Yao Wang, NYU-Poly EL5123: color and quantization 9 Demo with Photoshop

• Show the mixing using RGB, CMY colors – Using the “window>color” tool (in “show color”, click on right arrow button to choose different color sliders) (can also click F6) – Sample image: RGBadd, CMYsub • Use the dropper tool, click on different part of the image, see the color information in “show color” • Select different color coordinates

Yao Wang, NYU-Poly EL5123: color and quantization 10 A Color Image

Red

Green Blue

Yao Wang, NYU-Poly EL5123: color and quantization 11 Tristimuls Values • Tristimulus value – The amounts of red , green , and blue needed to form any particular color are called the tristimulus values, denoted by X, Y, and Z. – Trichromatic coefficients X Y Z x  , y  , z  . X Y  Z X Y  Z X Y  Z – Only two chromaticity coefficients are necessary to specify the chrominance of a light. x  y  z 1

Yao Wang, NYU-Poly EL5123: color and quantization 12 CIE Chromaticity Diagram

CIE (Commission Internationale de L’Eclairage, International Commission on Illumination ) system of color specification x axis: red y axis: green e.g. GREEN: x: 25%, y: 62%, z: 13%.

Colors on the boundary: spectrum colors , highest saturation

Yao Wang, NYU-Poly EL5123: color and quantization 13 Color Gamut

A line segment indicates all colors that can be produced by mixing two colors corresponding to the end points of the line. EhEach co lor mo dlhdifftdel has different co lor range (or gamu t)RGBdlht). RGB model has a larger gamu tthCMYt than CMY. Therefore, some color that appears on a screen may not be printable and is replaced by the closest color in the CMY gamut.

Yao Wang, NYU-Poly EL5123: color and quantization 14 Demo with Photoshop

• Using photoshop to show how to replace a out of gamut color by its closest in-gamut color. • Choose “window->show color”, choose the “CMYK slider” • While having “RGBadd” in display, use Eyedropper tool to click on “red”, “green” or “blue”, you will see a warning about out of gamut color, and the suggested replacement color • Also open “gamut” image, click on out of gamut region

Yao Wang, NYU-Poly EL5123: color and quantization 15 Three Attributes of Color

• Luminance (brightness) • Chrominance – Hue (color tone) and Saturation (color purity) • Represented by a “color cone” or “color solid”

θ

Yao Wang, NYU-Poly EL5123: color and quantization 16 Color Models

• Specify three primary or secondary colors – Red, Green, Blue. – Cyan, Magenta, Yellow. • Specify the luminance and chrominance – HSB or HSI (Hue, saturation, and brightness or intensity) – YIQQ( (used in NTSC color TV) – YCbCr (used in digital color TV) • Amplitude specification: – 8 bits per color component, or 24 bits per pixel – Total of 16 million colors – A 1kx1k true RGB color requires 3 MB memory

Yao Wang, NYU-Poly EL5123: color and quantization 17 RGB Color Model

RGB 24-bit color cube

Yao Wang, NYU-Poly EL5123: color and quantization 18 CMY and CMYK Color Models

• Conversion between RGB and CMY (assuming maximum value is 1)

 C  1 R R 1  C              M   1  G, G  1  M .  Y  1 B B 1  Y 

• Equal amounts of Cyan, Magenta, and Yellow produce black. In pppractice, this produce mudd y-looking black. To produce true black, a fourth color, black is added, which is CMYK color model.

Yao Wang, NYU-Poly EL5123: color and quantization 19 HSI Color Model

•Huerepresents dominant color as perceived by an observer. It is an attribute associated with the dominant wavelength. • Saturation refers to the relative purity or the amount of white light mixed with a hue. The pure spectrum colors are fully saturated. Pink and lavender are less saturated. • Intensity reflects the brightness.

Yao Wang, NYU-Poly EL5123: color and quantization 20 Conversion Between RGB and HSI

• Converting color from RGB to HSI

  1  (R  G)  (R  B)  if B  G 1 2  H   with   cos   360  if B  G 1   2 2  (R  G)  (R  B)(G  B)  3 S  1 [min(R,G, B)] (R  G  B) 1 I  [R  G  B] 3 • Converting color from HSI to RGB RG sector (0≤H<120) GB sector (120≤H<240) BR sector (240≤H<360) B  I(1 S) R  I(1 S) G  I(1 S)  S cos(H 120)     S cos H  G  I 1 S cos(H  240) R  I 1    B  I 1   cos(60  H )  cos(60  (H 120))  cos(60  (H  240)) G 1 (R  B) B 1 (R  G) R 1 (G  B)

Yao Wang, NYU-Poly EL5123: color and quantization 21 YIQ Color Coordinate System

• YIQ is defined by the National Television System Committee (NTSC) – Y describes the luminance, I and Q describes the chrominance. – A more compact representation of the color. – YUV plays similar role in PAL and SECAM. • Conversion between RGB and YIQ Y  0.299 0.587 0.114 R R 1.0 0.956 0.621 Y             I   0.596  0.274  0.322G, G  1.0  0.272  0.649 I  Q 0.211  0.55323 0.311 B B 1.0 1.106 1.703 Q

Yao Wang, NYU-Poly EL5123: color and quantization 22 YUV/YCbCr Coordinate

• YUV is the color coordinate used in color TV in PAL system, somewhat different from YIQ. • YCbCr is the digital equivalent of YUV, used for digital TV, with 8 bit for each component, in range of 0-255

Yao Wang, NYU-Poly EL5123: color and quantization 23 Demo with Photoshop

• Show the RGB, CMY, HSI models – Using the “window>show color” tool (in “show color”, click on right arrow button to choose different color sliders) – Sample image: RGBadd, CMYsub, fruit • Use the dropper tool, click on different part of the image, see the color information in “show color” • Select different color coordinates

Yao Wang, NYU-Poly EL5123: color and quantization 24 Criteria for Choosing the Color Coordinates • The type of representation depends on the applications at hand. – For display or printing, choose primary colors so that more colors can be produced. E. g. RGB for displaying and CMY for printing. – For analytical analysis of color differences, HSI is more suitable. – For transmission or storage, choose a less redundant representation, eg. YIQ or YUV or YCbCr

Yao Wang, NYU-Poly EL5123: color and quantization 25 Comparison of Different Color Spaces

Yao Wang, NYU-Poly EL5123: color and quantization 26 Pseudo Color Display

• Intensity slicing: Display different gray levels as different colors – Can be useful to visualize medical / scientific / vegetation imagery • E.g. if one is interested in features with a certain intensity range or several intensity ranges • Frequency slicing: Decomposing an image into different frequency components and represent them using different colors.

Yao Wang, NYU-Poly EL5123: color and quantization 27 Intensity Slicing

Color

C4

C3

C2

C1

f0 =0 f1 f2 f3 f4 Gray level

Pixels with gray -scale (intensity) value in the range of ( f i-1 , fi) are rendered with color Ci

Yao Wang, NYU-Poly EL5123: color and quantization 28 Example

Yao Wang, NYU-Poly EL5123: color and quantization 29 Another Example

Yao Wang, NYU-Poly EL5123: color and quantization 30 Pseudo Color Display of Multiple Images

• Display multi-sensor images as a single color image – Multi-sensor images: e.g. multi-spectral images by satellite

Yao Wang, NYU-Poly EL5123: color and quantization 31 An Example

Yao Wang, NYU-Poly EL5123: color and quantization 32 Example

Yao Wang, NYU-Poly EL5123: color and quantization 33 Three Processes in A/D Conversion

Sampling Quanti- Binary zation Encoding xc(t) x[n] = xc(nT) xn[] c[n]

Sampling Quantization Binary PidPeriod ItInterval codebook T Q • Sampling: take samples at time nT – T: sampling period;

– fs = 1/T: sampling frequency • Quantization: map amplitude values into a set of discrete values kQ – Q: quantization interval or stepsize • Binaryyg Encoding – Convert each quantized value into a binary codeword

Yao Wang, NYU-Poly EL5123: color and quantization 34 Analog to Digital Conversion

1 T=0.1 Q=0.25

0.5

0

-0.5 A2D_plot . m

-1

0 020.2 040.4 060.6 080.8 1

Yao Wang, NYU-Poly EL5123: color and quantization 35 How to determine T and Q?

• T (or fs) depends on the signal frequency range – A fast varying signal should be sampled more frequently! – Theoretically governed by the Nyquist sampling theorem

• fs > 2 fm (fm is the maximum signal frequency) • For speech: fs >= 8 KHz; For music: fs >= 44 KHz; • Q depends on the dynamic range of the signal amplitude and perceptual sensitivity – Q and the sigggnal range D determine bits/sample R • 2R=D/Q • For speech and image: R = 8 bits; For music: R =16 bits;

• One can trade off T (or fs) and Q (or R) – lower R -> higher fs; higher R -> lower fs • We discuss quantization in this lecture. We will discuss sampling later.

Yao Wang, NYU-Poly EL5123: color and quantization 36 A Quantizer

Q(f) f Quantizer Q(f)

r7 Decision Levels {tk, k = 0, …, L} r6 Reconstruction Levels {rk, k = 0, …, L-1} r5 If f [tk ,tk 1) r4 Then Q(f) = r f k t t t t t t 1 2 3 4 5 t6 7 r L levels need R   log2 L bits 3 returns the smallest integer r x 2 that is bigger than or equal to x Quantizer r1 error

r0 r0 r1 r2 r3 r4 r5 r6 r7 f t0=-∞ t1 t2 t3 t4 t5 t6 t7 t8=∞

Yao Wang, NYU-Poly EL5123: color and quantization 37 Uniform Quantization

• Equal distances between adjacent decision levels and between adjacent reconstruction levels

– tl – tl-1 = rl – rl-1 = q • Parameters of Uniform Quantization – L: levels (L = 2R)

– B: dynamic range B = fmax –fmin – q: quantization interval (step size) – q = B/L = B2-R • Quantization function

NtNote: x  f  fmin  q   Q( f )    q   fmin  q  2 returns the biggest integer that is smaller than or equal to x

Yao Wang, NYU-Poly EL5123: color and quantization 38 Uniform Quantization: Functional Representation

Q(f)

r7=fmax-q/2

r6

r5

r4 stepsize q=(fmax-fmin)/8 r3

r2

r1

r0=fmin+q/2 f t t t t t t t t t0 1 2 3 4 5 6 7 8 fmin fmax

Yao Wang, NYU-Poly EL5123: color and quantization 39 Truncated Uniform Quantization • Signal with infinite dynamic range • Truncate the lower and higher values to fmin and fmax • Parameters

– fmin, fmax – L(R)L (R) • Quantization function

 f  fmiin  q  q   fmin fmin  f  fmax  q  2   Q( f )   fmin  q / 2 f  fmin  f  q / 2 f  f  max max 

Yao Wang, NYU-Poly EL5123: color and quantization 40 Truncated Uniform Quantization: Functional Representation

Q(f) overload region r7=fmax-q/2

r6

r5

r4

r3

r2

r1

r0=fmin+q/2 f t0 =-∞ fmin t1 t2 t3 t4 t5 t6 t7 fmax t8 =∞ overload region

Yao Wang, NYU-Poly EL5123: color and quantization 41 Example 1 of Uniform Quantizer

• Input signal is continuous – The output of a Charge-Coupled Device (CCD) camera is in the range of 0.0 to 5.0 volt. – L = 256 – q = 5. 0 / 256 – The output value in the interval (l * q, (l + 1) * q] is represented by index l, l = 0, …, 255.

– The reconstruction level rl = l * q + q/2, l = 0,,,…, 255.

Yao Wang, NYU-Poly EL5123: color and quantization 42 Example 2 of Uniform Quantizer

• Input signal is discrete – Digital Image of 256 gray levels – Quantize it into 4 levels

– fmin= 0,

– fmax = 256, – q = 256 / 4 = 64, – q/2 = 32, – Q( f )  f / 64*64  32

Yao Wang, NYU-Poly EL5123: color and quantization 43 Uniform Quantization on Images 256 32 == q=8, L= riginal, L OO , L=4 6, L=16 44 11 q= q=6

Yao Wang, NYU-Poly EL5123: color and quantization 44 Quantizer Performance

• Ideally we want to measure the performance by how close is the quantized image to the original image -- Perceptual Difference • But it is very hard to come up with an objective measure that correlates very well with the perceptual quality • Frequently used objective measure – mean square error (MSE) between original and quantized samples or signal to noise ratio (SNR) or Peak SNR (PSNR)

Yao Wang, NYU-Poly EL5123: color and quantization 45 MSE

• Mean square error (MSE) of a quantizer for a continuous valued signal 2 2 MSE   q  E{(Q( f )  f ) } 

t L1 t Ll2 1 2 ( f  Q( f )) p( f )df  ( f  rl ) p( f )df t t 0 l0 l – Where p(f) i s th e prob abilit y dens ity func tion o f f • MSE for a specific image N 1 M 1 2 1 2 MSE   q  ( f (i, j)  Q( f (i, j))) MN i0 j0

Yao Wang, NYU-Poly EL5123: color and quantization 46 SNR and PSNR

• Signal to Noise Ratio (SNR)

 2 SNR(dB)  10log f 2  q N 11M  2 1 2 Signal Variance  Signal Energy   f  ( f (i, j)  mean) MN ij00

• PkSNRPeak SNR – For the error measure to be independent of the signal energy, use the dy namic range square of the image as 2552 the signal energy PSNR(dB)  10log 2 – For 8 bit image, peak=255  q

Yao Wang, NYU-Poly EL5123: color and quantization 47 MSE of a Uniform Quantizer for A Uniform Source

1/( fmax  fmin )  1/ B, f  ( fmin , fmax ) p( f )     0, otherwise f 2 2 max 2 1 B f  f  df  f  min B 12

Uniform quantization into L levels: q  B / L  B / L Error in each bin is the same, and is uniformly distributed in (-q/2, q/2) 2 q / 2 2 B  2 2 2 1 q L B 2R 2 2R q  e de    2   f 2 q / 2 q 12 12 12  2 SNR  10log f  10log 22R  20R log 2  6R(dB) 10 2 10 10  q Every additi onal bit increases the SNR by 6dB!

Yao Wang, NYU-Poly EL5123: color and quantization 48 Example: Nonuniform Source

• The pdf of a signal is shown below, we want to quantize it to 2 levels. Determine the partition and reconstruction levels that minimizes the quantization error (in terms of MSE). Also compute the MSE and SNR. • Go through in class .

p(f) 1/2

Exp(f) Exp(-f) f

Yao Wang, NYU-Poly EL5123: color and quantization 49 MMSE Quantizer

• For any pdf, the quantizer that minimizes MSE is known as Minimal MSE (MMSE) quantizer. • For uniform source , what is the MMSE quantizer?

Yao Wang, NYU-Poly EL5123: color and quantization 50 Implementation of Quantization

• Two options • Option 1: – At each pixel, calculating quantized value for the given pixel value – For unif orm quanti titization, i nc ldiluding one diiidivision an d rounding, then multiplication – Must repeat for all pixels • Option 2: – Precompute the quantized values for all possible input values and save in a look-up table – Change each pixel based on the look-up table • Which one is more efficient?

Yao Wang, NYU-Poly EL5123: color and quantization 51 Sample Matlab Code for Option 2

• Setup the quantization function Q(f) for all possible input level first. x = id('l2568b')imread('lena256_8.bmp'); • Matlab code [height, width] = size(x); x=int(x); B = 256; %Qi% Q is the quan tiza tion tabl e Q = zeros(256, 1); % Quantized to 64 levels L = 16; qB/Lq = B / L; for i = 0:255, Q(i+1, 1) = floor(i / q) * q + q /2; end y = zeros(size(x)); for i = 1:height, for j = 1:width, y(i, j) = Q(x(i,j) + 1); L = 16, MSE = 21. 6 end End Is there a more efficient implementation? MSE = mean(mean((x-y).^2));

Yao Wang, NYU-Poly EL5123: color and quantization 52 Quantization Effect – False Contour

ˆ • 1-D Signal f(t) f (t)

• 2-D Image t t x=zeros(256, 256); for I =1:256, for j = 1:256, x(i,j)=max(i,j)-1; end end Figure; imshow(uint(x));

f(i,j)=max(I,j)

Yao Wang, NYU-Poly EL5123: color and quantization 53 Perception Optimized Quantization

• Reduce the artifact of false contour • Better v isu al perception (Hu man ey es are very sensitive to edges) • MSE might be worse

Yao Wang, NYU-Poly EL5123: color and quantization 54 Pseudo Random Noise Quantizer

f Uniform Quantizer ˆ ˆ + g g + f + Q() + Step size: q + -

h

Random Noise Why do we first subtract and Generator then add back the random noi?Whtifise? What if we ski p one of Uniform in (-q/2, q/2) them?

Yao Wang, NYU-Poly EL5123: color and quantization 55 Example

• Comparison

8 Level Pseudo Random 8 Level Uniform Quantizer NooseQuaise Quan tiz eer MSE=83.7 MSE=173.45 Which one is better to your eye? Yao Wang, NYU-Poly EL5123: color and quantization 56 Halftoning

• Halftoning – Representing gray scale image using 2 levels (black and white) • Used for printing gray scale photographs in B/W newspaper/fax • Can be extended to more than two levels Two Level Quantizer f ˆ + g f f + w + fb

Why don’t we subtract the added Signal dithered signal? d

Yao Wang, NYU-Poly EL5123: color and quantization 57 Color Quantization

• In low end monitors, the monitor cannot display all possible colors. • Select a set of colors, save them in a look-up table (also known as color map or color ) • Any color is quantized to one of the indexed colors • Only needs to save the index as the image pixel value and in the disppylay buffer • Typically: k=8, m=8 (selecting 256 out of 16 million)

Input index (k bits) Red color (m bits) Green color (m bits) Blue color (m bits)

Index 1 … … …

……. … … …

Index 2^k … … … Yao Wang, NYU-Poly EL5123: color and quantization 58 : 216 Safe RGB Colors

These colors are those that can be rendered consistently by different computer systems. They are obtained by quantizing the R,G,B component independently using uniform quanitization. Each component is quantized to 6 possibl e val ues: 0(0 x00) , 51(0x 33), 102(0x 66), 153(0x 99), 204(0x CC), 255(0x FF).

Yao Wang, NYU-Poly EL5123: color and quantization 59 Uniform vs. Adaptive Quantization • Uniform (scalar quantization) – Quantize each color component uniformly • E.g. 24 bit-> 8 bit can be realized by using 3 bits (8 levels) for red, 3 bits (8 levels) for green, 2 bits (4 levels) for blue • Do not ppgroduce good result • Adaptive (vector quantization) – Treat each color (a 3-D vector))y as one entity. Find the N colors (vectors) that appear most often in a given image, save them in the color palette (codebook). Replace the color at each pixel by the closest color in the codebook – The codebook (I.e. color palette) varies from image to image -> adaptive

Yao Wang, NYU-Poly EL5123: color and quantization 60 Illustration of Vector Quantization

yyCodebook size: 25

x x

Uniform Quantization Vector Quantization

Yao Wang, NYU-Poly EL5123: color and quantization 61 Example of Color Quantization

24 bits -> 8 bits

Uniform quantization Adaptive (non-uniform) quantization (3 bits for R,G, 2 bits for B) (vector quantization)

Yao Wang, NYU-Poly EL5123: color and quantization 62 Color Dithering

• Color quantization may cause contour effect when the number of colors is not sufficient • Dithering: randomly perturb the color values slightly to break up the contour effect, by applying the dithering technique for gray scale images to each color component – fixed pattern or random noise dithering – diffusion dithering (the perturbed value of the next pixel depends on the previous one)

Yao Wang, NYU-Poly EL5123: color and quantization 63 Example of Color Dithering

8 bit uniform 8 bit uniform without dithering with diffusion dithering

Yao Wang, NYU-Poly EL5123: color and quantization 64 Demo Using Photoshop

• Show quantization results with different methods using “image->mode->index color”

Yao Wang, NYU-Poly EL5123: color and quantization 65 Homework

1. Describe how the cones in the retina behind the human eye enable us to perceive color. What are the different types of cones we have? what colors are they each sensitive to? 2. What color do you see when you project equal amounts of red, green and blue lights on a screen? What about red and green, and green and blue? 3. What color do you see when you mix equal amounts of?f cyan, magenta, and yellow? What about cyan and magenta, magenta and yellow? what about mixing red, green, and blue in equal proportions? 4. Consider the conversion between RGB and YCbCr coordinate. a) Determine the YCbCr coordinate for a color that is specified in (R,G,B) coordinate with R=100,G=200, B=50. b) Determine the (R, G, B) coordinate for a color specified in the YCbCr coordinate with Y=100,Cb=50,Cr=30. Note that if you get R,G,B values that are outside the range of (0,255) you should clip the values, so that values below 0 become 0, and values above 255 become 255. 5. Suppose you are given a 24 bit color image, with color components red, green, blue each represented by 8 bits per pixel. Now, we would like to reduce it to an 8 bit image by uniformly quantizinggg the red and green components to 3 bits each, and the blue component to 2 bits. Illustrate the quantizer that you would use for different components. For designing the quantizer, you should assume the image values are uniformly distributed between 0 and 256 (instead of 255). Suppose a pixel has a color value of (R,G,B)=(200, 150, 40). What is the color after quantization? 6. Consider a source with a pdf as shown below. If we want to quantize it into L=3 levels, what should be the decision levels and reconstruction levels? Illustrate the results on the pdf, and compute the quantizer MSE and SNR.

p(f) 1

-1 1 f

Yao Wang, NYU-Poly EL5123: color and quantization 66 Computer Assignment

1. Using Matlab or C, to implement uniform quantization of a grayscale image. Your program should do the following: i) read a grayscale image into an array; ii) quantize and save the quantized image in a different array; iii) compute the MSE, SNR, and PSNR between the origgqinal and quantized ima ges; and iv )pyp) display and print the quantized image. Your program should assume the input values are in the range of (0,256), but allow you to vary the reconstruction level (L). Record the MSE obtained with L=64, 32, 16, 8, and print the quantized images with corresponding L values. Include the program, the image printout and MSE/SNR/PSNR values in your submission. Comment on the imaggqe qualit y as you var y L. 2. Choose a 24 bit color RGB image, quantize the R, G, and B components to 3, 3, and 2 bits, respectively, using a uniform quantizer. Display the original and quantized color image. Comment on the difference in color accuracy. Make sure you use a computer that has a 24 bit color display, and the test image has good color contrast. Note you can apply the uniform quantization function developed for Prob. 1 to each color component. For this assignment, please include color printout of original and quantized images. If you don’t have access to color printer, include a disk containing your image files, or email the files to the grader. 3. Choose a 24 bit RGB color image, convert it to HSI format, and display the HSI components as separate gray scale images. Observe these images to comment on what does each of the H, S, I components represent. Include printout of the images and your program and comments in your report. For this assignment, you should not use the MATLAB built-in function for RGB to HSV conversion. You should write your own function. The HSV images should be saved in double precision. You can use imagesc( ) to display these images directly , which automatically scale each image to a gray scale between 0-255.

Yao Wang, NYU-Poly EL5123: color and quantization 67 Reading

• Gonzalez, “Digital Image Processing”, Chapter 2 (Section 212.1, 222.2, 232.3, 2412.4.1 – 2.4.3), Chap. 6. (Sec. 6.1-6.3), Sec. 8.2 (p602-603, MMSE quantizer) • Jain, “Fundamentals of Digital Image Processing”, Chapter 4 (Section 4. 5 – 4.11)

Yao Wang, NYU-Poly EL5123: color and quantization 68