image processing 10
play

Image Processing (10) RNDr. Martin Madaras, PhD. - PowerPoint PPT Presentation

Principles of Computer Graphics and Image Processing Image Processing (10) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk Computer Graphics Image processing Representing and manipulation of 2D images Modeling Representing and


  1. Principles of Computer Graphics and Image Processing Image Processing (10) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk

  2. Computer Graphics  Image processing  Representing and manipulation of 2D images  Modeling  Representing and manipulation of 2D and 3D objects  Rendering  Constructing images from virtual models  Animation  Simulating changes over time 2

  3. How the lectures should look like #1 Ask questions, please!!! - Be communicative - www.slido.com #PPGSO10 - More active you are, the better for you! - 3

  4. Image Processing - Image Filtering / Image Manipulation - Pixel operations Filtering - Composition - Quantization - Warping and Morphing - Sampling, Reconstruction and Aliasing - 4

  5. Pixel operations - Change the color values of every pixel - P’ = F(P) 5

  6. Adding noise - Add random value to each color channel - Clamp to <0,1> range 6

  7. Change brightness  Simply scale pixel values and clamp to <0,1> range 7

  8. Change contrast  Compute mean luminance L = 0.3r+0.59g+0.11b  Scale deviation from L and clamp to <0,1> 8

  9. Grayscale  r’, g’, b’ = 0.3r+0.59g+0.11b 9

  10. Linear filtering  Discretized convolution of functions  Each pixel is a linear combination of pixels in its neighborhood 10

  11. Blur  Convolve with a filter that sums to 1 11

  12. Edge detection  Convolve with a filter that finds differences between pixels 12

  13. Sharpen  Sum edges with original image 13

  14. Non Linear filtering  Each pixel is non-linear function of input pixels  A non-linear filter is one that cannot be done with convolution or Fourier multiplication  The median is NOT linear because  med( f{i} + g{i} ) != med( f{i} ) + med( g{i} )  med( {1,2,3} + {5,4,6}) = med( {6,6,9} ) = 6  med( {1,2,3} ) + med( {5,4,6} ) = 2 + 5 14

  15. Blending  Combine multiple images, produce new image  Per-pixel operation  blend = F( base , source )  Image dimensions may not be identical 15

  16. Normal Blending  Linear combination of pixels from both images  blend(x,y) = base(x,y)(1-t) + source(x,y)t  t is from <0,1> t = 0 t = 0.5 t = 1 base blend source 16

  17. Normal Blending  Linear combination of pixels from both images  blend(x,y) = base(x,y)(1-t) + source(x,y)t  t is from <0,1> t = 0 t = 0.5 t = 1 base blend source 17

  18. Linear Interpolation  Compute value v that is a linear combination of v0 and v1  Use argument t to specify how close v is to v1 using <0,1> range v = v0*(1-t)+v1*t float lerp(float v0, float v1, float t) { return v0*(1-t)+v1*t; } 18

  19. Additive Blending  Add pixels from both images  Clamp the result into the <0,1> range  blend(x,y) = base(x,y) + source(x,y) base source base + source 19

  20. Subtract  Subtract pixels from both images  Clamp the result into the <0,1> range  blend(x,y) = base(x,y) - source(x,y) base source base - source 20

  21. Difference  Compute the difference between images  White source inverts base  blend(x,y) = abs(source(x,y)-base(x,y)) base source |source-base| 21

  22. Masking  How to blend parts of the image?  We need a way to select sections of the image  Idea. How about using another image ... ? 22

  23. Mask  White region is transparent  Black regions are opaque  Use a 1-bit image to select areas of interest base mask masked area 23

  24. Mask composition  Blend two images with mask  blend(x,y) = base(x,y) if mask(x,y) is 1  blend(x,y) = source(x,y) if mask(x,y) is 0 base + source composite 24

  25. Mask Problems  Masks are 1-bit, no smooth edges  What about transparent objects such as glass?  We need to work with additional image? 25

  26. Alpha Blending  Idea. Store pixel transparency per pixel!  Alvy Ray Smith, late1970s  Pixel = (r, g, b, a ), added alpha channel  Let a define the opacity of the pixel  a = 0, pixel is transparent  a = 1, pixel is opaque  Opacity depth is usually same as for colors 26

  27. Premultiplied Color  Thomas Porter and Tom Duff, 1984  (r, g, b, a ) represents a pixel that is a covered by the color C=(r/ a , g/ a , b/ a )  Store components premultiplied by a  We can display (r, g, b) values directly  Why? Closure in composition algebra  Note: Many images do not use premultiplied color 27

  28. Premultiplied Color  What is the meaning of the following?  (0, 1, 0, 1) =  (0, ½, 0, 1) =  (0, ½, 0, ½) =  (0, ½, 0, 0) = 28

  29. Premultiplied Color  What is the meaning of the following?  (0, 1, 0, 1) = full green, opaque  (0, ½, 0, 1) = half green, opaque  (0, ½, 0, ½) = full green, partially transparent  (0, ½, 0, 0) = transparent 29

  30. Semi-transparent Objects  Suppose we put A over B over background G  How much of B is blocked by A ? A B G 30

  31. Semi-transparent Objects  Suppose we put A over B over background G  How much of B is blocked by A ?  a A A B G 31

  32. Semi-transparent Objects  How much of B is shown through A ? A B G 32

  33. Semi-transparent Objects  How much of G is shown through both A and B? A B G 33

  34. Semi-transparent Objects  How much of G is shown through both A and B?  (1- a A) (1- a B) A B G 34

  35. Opaque Objects  How do we combine 2 partially covered objects?  3 Possible colors (0, A, B)  4 Regions (0, A, B, AB) 35

  36. Composition Algebra  12 reasonable combinations 36

  37. Example: C = A over B  For colors that are not premultiplied :  C = A a A + (1 – a A) B a B  a C = a A + (1 – a A) a B  For colors that are premultiplied :  C = A + (1 – a A) B  a C = a A + (1 – a A) a B 37

  38. Example: Masks  Photoshop masks and layers 38

  39. Example: Transparency  Multiple blend modes and transparency 39

  40. Example: Green Screen 40

  41. Image Processing - Image Filtering / Image Manipulation - Pixel operations Filtering - Composition - Quantization - Warping and Morphing - Sampling, Reconstruction and Aliasing - 41

  42. Image Processing - Image Filtering / Image Manipulation - Pixel operations Filtering - Composition - Quantization - Halftoning - Dithering - Warping and Morphing - Sampling, Reconstruction and Aliasing - 42

  43. Quantization  Artifact due to limited intensity resolution  Frame buffers have limited number of bits per pixel  Physical devices have limited dynamic range 43

  44. Uniform Quantization P(x,y) = trunc(I(x,y)) 44

  45. Quantization  Grayscale image with decreasing bits per pixel  How to prevent dramatic decrease in quality? 45

  46. Reducing Effects of Quantization  Halftoning  Classical halftoning  Halftoning Patterns  Dithering  Random dither  Ordered dither  Error diffusion dither 46

  47. Classical Halftoning  Use dot size to represent intensity  Area of dots proportional to intensity in image 47

  48. Halftone Patterns  Use cluster of pixels to represent intensity  Trade spatial resolution for intensity resolution  How many intensities are there for n x n? 48

  49. Dithering  Distribute errors among pixels  Exploit spatial integration in our eye  Display greater range of perceptible intensities 8bit 1bit 1bit dithered 49

  50. Random Dither  Randomize quantization errors  Errors will appear as noise  P(x,y) = trunc(I(x,y)+noise(x,y)) 50

  51. Random Dither  Results are ... Random 8 bit 1 bit 1bit random dither 51

  52. Ordered Dither  Pseudo-random quantization errors  Matrix stores pattern of thresholds n = 2 for each y for each x oldpixel = I[x][y] + D[x mod n][y mod n] P[x][y] = trunc(oldpixel) 52

  53. Ordered Dither  Slightly better result 8 bit 1 bit 1 bit Ordered dither 53

  54. Error Diffusion Dither  Errors are distributed to pixels right and below  Robert W. Floyd and Louis Steinberg, 1976  for each y  for each x  P[x][y] = trunc(I[x][y])  # Pass error to other pixels  e = I[x][y] - P[x][ y]  I[x+1][y] = I[x+1][y]+7/16*e  I[x-1][y+1] = I[x-1][y+1]+3/16*e  I[x][y+1] = I[x][y+1]+5/16*e  I[x+1][y+1] = I[x+1][y+1]+1/16*e 54

  55. Dither Comparison 8 bit 1 bit 1 bit 1 bit Original Random Ordered Floyd-Steinberg 55

  56. Image Processing - Image Filtering / Image Manipulation - Pixel operations Filtering - Composition - Quantization - Warping and Morphing - Scale - Rotate - Arbitrary Warps - Sampling, Reconstruction and Aliasing - 56

  57. Warping - Transform image pixels - Mapping Forward - Inverse - - Resampling 57

  58. Mapping - Define image transformation Describe the destination (x, y) for every location (u, v) in the source (or - vice-versa, if inversible) v y u x 58

Recommend


More recommend