Image Characteristics Image Digitization Spatial domain Intensity domain 1 What is an Image ? • An image is a projection of a 3D scene into a 2D projection plane. • An image can be defined as a 2 variable function f(x,y): R2R , where for each position (x,y) in the projection plane, f(x,y) defines the light intensity at this point. 2 Image as a function 3 Image Acquisition g(i,j) i(x,y) f(x,y)=i(x,y)r(x,y) r(x,y) pixel=picture element 4 Acquisition System World Camera Digitizer CMOS sensor Digital Image 5 Image Types Three types of images: – Binary images g(x,y) {0 , 1} – Gray-scale images g(x,y) C typically c={0,…,255} – Color Images three channels: gR(x,y)C gG(x,y)C gB(x,y)C 6 Gray Scale Image x = 58 y= 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 210 206 201 216 221 209 204 214 209 208 207 208 204 200 205 59 60 61 62 63 64 65 66 67 68 69 70 71 72 209 196 207 206 206 214 212 215 205 209 210 205 206 203 210 204 203 192 211 211 224 213 215 214 205 211 209 203 199 202 202 197 201 193 194 199 208 207 205 203 199 209 209 236 203 197 195 198 202 196 194 191 208 204 202 217 197 195 188 199 247 210 213 207 197 193 190 180 196 186 194 194 203 197 197 143 207 156 208 220 204 191 172 187 174 183 183 188 183 196 71 56 69 57 56 173 214 188 196 185 177 187 185 190 181 64 63 65 69 63 64 60 69 86 149 209 187 183 183 173 80 84 54 54 57 58 58 53 53 61 62 51 57 55 52 53 60 50 60 55 77 49 62 61 60 55 46 97 58 106 60 59 51 62 56 48 62 66 76 51 49 55 72 55 49 56 52 56 62 66 87 57 60 48 71 63 55 55 45 56 90 62 64 52 93 52 239 58 68 61 51 56 221 75 61 58 60 60 196 122 63 58 64 66 186 105 62 57 64 63 7 Color Image 8 Notations • Image Intensity – Light energy emitted from a unit area in the image – Device dependence • Image Brightness – The subjective appearance of a unit area in the image – Context dependence – Subjective • Image Gray-Level – The relative intensity at each unit area – Between the lowest intensity (Black value) and the highest intensity (White value) – Device independent 9 Intensity vs. Brightness 10 f1 < f2, Df1 = Df2 Intensity Intensity vs. Brightness Df2 Df1 f2 f1 Equal intensity steps: Equal brightness steps: 11 Weber Law • Describe the relationship between the physical magnitudes of stimuli and the perceived intensity of the stimuli. • In general, Df needed for just noticeable difference (JND) over background f was found to satisfy: Df const f Brightness log(f) 12 What about Color Space? • JND in XYZ color space was measured by Wright and Pitt, and MacAdam in the thirties • MacAdam ellipses: JND plotted at the CIE-xy diagram • Conclusion: measuring perceptual distances in the cie-XYZ space is not a good idea Perceptually Uniform Color Space • Most common: CIE-L*a*b* (CIELAB) color space. • L* represents luminance. • a* represents the difference between green and red, and b* represents the difference between yellow and blue. Perceptually Uniform Color Space • XYZ to CIELAB conversion: 200 X a * 500 X X 0 b * 1/ 3 X0 1/ 3 Y Y0 1/ 3 Z Z 0 1/ 3 116Y Y0 16 * L 903Y Y0 1/ 3 for Y Y0 0.01 otherwise • where (X0,Y0,Z0) are the XYZ values of a reference white point Digitization • Two stages in the digitization process: – Spatial sampling: Spatial domain – Quantization: Gray level f j x 1 2 3 4 5 1 100 100 100 100 100 y i 2 100 0 0 0 100 3 100 0 0 0 100 4 100 0 0 0 100 5 100 100 100 100 100 Continuous Image f(x,y) Digital Image g(i,j) C 16 Spatial Sampling • When a continuous scene is imaged on the sensor, the continuous image is divided into discrete elements - picture elements (pixels) Spatial Sampling Sampling • The density of the sampling denotes the separation capability of the resulting image • Image resolution defines the finest details that are still visible by the image • We use a cyclic pattern to test the separation capability of an image numberof cycles Frequency unit length 1 Wavelength frequency 0 x Sampling Rate Nyquist Frequency • Nyquist Rule: To observe details at frequency f (wavelength d) one must sample at frequency > 2f (sampling intervals < d/2) • The Frequency 2f is the Nyquist Frequency. • Aliasing: If the pattern wavelength is less than 2d erroneous patterns may be produced. 1D Example: 0 Aliasing - Moiré Patterns Temporal Aliasing Temporal Aliasing Example Image De-mosaicing • Can we do better than Nyquist? Image De-mosaicing • Basic idea: use correlations between color bands A joint Histogram of rx v.s. gx 500 450 Green derivative 400 350 300 250 200 150 100 50 100 200 300 Red derivative 400 500 Quantization • Choose number of gray levels (according to number of assigned bits) • Divide continuous range of intensity values Quantization Quantization • Low freq. areas are more sensitive to quantization 8 bits image 4 bits image How should we quantize an image? • Simplest approach: uniform quantization 10 Zk Z0 Z i 1 Z i K 8 Gray-Level Z i 1 Z i qi 2 6 4 2 0 0 10 20 30 40 50 60 70 80 90 Sensor Voltage q0 Z0 q1 Z1 q2 Z2 .... .... q3 Z3 Z4 .... Zk-1 quantization level qk-1 Zk sensor voltage 100 Non-uniform Quantization • Quantize according to visual sensitivity (Weber’s Law) • Non uniform sensor voltage distribution q 0 q1 q2 q3 Z0 Z1 Z2 Z3 High Visual Sensitivity q4 Z4 q5 Z5 q6 Z6 Z7 Low Visual Sensitivity Optimal Quantization (Lloyd-Max) • Content dependant • Minimize quantization error q0 q1 q2 q3 quantization level sensor voltage Z0 Z1 Z2 Z3 Z4 Optimal Quantization (Lloyd-Max) • Also known as Loyd-Max quantizer • Denote P(z) the probability of sensor voltage • The quantization error is : k 1 zi 1 E P z z qi dz 2 i 0 zi zi1 • Solution: qi zPz dz zi zi1 Pz dz qi 1 qi zi 2 zi • Iterate until convergence (but optimal minimum is not guaranteed). Example 8 bits image 4 bits image Uniform quantization 4 bits image Optimal quantization Color Quantization • Common color resolution for high quality images is 256 levels for each Red, Greed, Blue channels, or 2563 = 16777216 colors. • How can an image be displayed with fewer colors than it contains? • Select a subset of colors (the colormap or pallet) and map the rest of the colors to them. from: Daniel Cohen-Or Color Quantization • With 8 bits per pixel and color look up table we can display at most 256 distinct colors at a time. • To do that we need to choose an appropriate set of representative colors and map the image into these colors 111 14 126 5 12 36 36 111 36 12 17 111 17 111 200 36 12 36 14 36 12 36 14 36 17 111 14 126 17 111 36 36 12 126 200 from: Daniel Cohen-Or 12 Color Quantization 2 colors 16 colors 4 from: Danielcolors Cohen-Or 256 colors Color Quantization Naïve (uniform) Color Quantization 24 bit to 8 bit: Retaining 3-3-2 most significant bits of the R,G and B components. false contours from: Daniel Cohen-Or Median Cut R G B Median Cut from: Daniel Cohen-Or Median Cut from: Daniel Cohen-Or Median Cut from: Daniel Cohen-Or Median Cut from: Daniel Cohen-Or Median Cut from: Daniel Cohen-Or The median cut algorithm Color_MedCut (Image, n){ For each pixel in Image with color C, map C in RGB space; B = {RGB space}; While (n-- > 0) { L = Heaviest (B); Split L into L1 and L2; Remove L from B, and add L1 and L2 instead; } For all boxes in B do assign a representative (color centroid); For each pixel in Image do map to one of the representatives; } from: Daniel Cohen-Or Better Solution from: Daniel Cohen-Or Generalized Lloyed Algorithm (GLA) pi 0 qi qi1 from: Daniel Cohen-Or Generalized Lloyed Algorithm (GLA) pi 0 qi qi1 from: Daniel Cohen-Or Generalized Lloyed Algorithm (GLA) pi 2 qi qi1 from: Daniel Cohen-Or • The GLA algorithms aims at minimizing the quantization error: K E p j qi 2 i 1 jCi Color_GLloyd(Image, K) { - Guess K cluster centre locations - Repeat until convergence { - For each data point finds out which centre it’s closest to - For each centre finds the centroid of the points it owns - Set a new set of cluster centre locations - optional: split clusters with high variance } } 24 8 bit 4 from: Daniel Cohen-Or More on Color Quantization • Observation 1: Distances and quantization errors measured in RGB space, do not relate to human perception. • Solution: Apply quantization in perceptually uniform color space (such as CIELAB). More on Color Quantization Original RGB Quantization Lab Quantization More on Color Quantization Sensitivity • Observation 2: Quantization errors are spatially dependent: we are more sensitive to errors at lower spatial frequencies. 1 3 10 30 100 Spatial Frequency More on Color Quantization • Solution: Assign weight for each pixel color • Using this scheme we minimize: W k 1 E w j p j qi i 0 jCi W W 2 250 200 w 150 100 50 0 300 200 100 W 0 0 50 w 100 150 200 250 Original Standard quantization Weighted quantization THE END 57