1 / 55

Introduction to Computer Vision

Introduction to Computer Vision. Lecture 4 Dr. Roger S. Gaborski. Intensity image is simply a matrix of numbers. We can summary this information by only retaining the distribution if gray level values:. PARTIAL IMAGE INFO:. 117 83 59 59 68 77 84

eyad
Télécharger la présentation

Introduction to Computer Vision

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computer Vision Lecture 4 Dr. Roger S. Gaborski

  2. Intensity image is simply a matrix of numbers We can summary this information by only retaining the distribution if gray level values: PARTIAL IMAGE INFO: 117 83 59 59 68 77 84 94 82 67 62 70 83 86 85 81 71 65 77 89 86 82 76 67 72 90 97 86 66 54 68 104 121 107 85 46 58 89 138 165 137 91 38 80 147 200 211 187 138 40 80 149 197 202 187 146 56 76 114 159 181 160 113 An image shows the spatial distribution of gray level values Roger S. Gaborski

  3. Image Histogram Plot of Pixel Count as a Function of Gray Level Value Pixel Count Gray Level Value Roger S. Gaborski

  4. Histogram • Histogram consists of • Peaks: high concentration of gray level values • Valleys: low concentration • Flat regions Roger S. Gaborski

  5. Formally, Image Histograms Histogram: • Digital image • L possible intensity levels in range [0,G] • Defined: h(rk) = nk • Where rk is the kth intensity level in the interval [0,G] and nk is the number of pixels in the image whose level is rk . • G: uint8 255 uint16 65535 double 1.0 Roger S. Gaborski

  6. Notation • L levels in range [0, G] • For example: • 0, 1, 2, 3, 4, in this case G = 4, L = 5 • Since we cannot have an index of zero, • In this example, index of: Index 1 maps to gray level 0 2 maps to 1 3 maps to 2 4 maps to 3 5 maps to 4 Roger S. Gaborski

  7. Normalized Histogram • Normalized histogram is obtained by dividing elements of h(rk) by the total number of pixels in the image (n): fork = 1, 2,…, L p(rk) is an estimate of the probability of occurrence of intensity level rk Roger S. Gaborski

  8. MATLAB Histogram • h = imhist( f, b ) • h is the histogram, h(rk) • f is the input image • b is the number of bins (default is 256) • Normalized histogram Roger S. Gaborski

  9. Color and Gray Scale Images Roger S. Gaborski

  10. Gray Scale Histogram Roger S. Gaborski

  11. Normalized Gray Scale Histogram >> p= imhist(Igray)/numel(Igray); >> figure, plot(p) Roger S. Gaborski

  12. Normalized Gray Scale Histogram imhist(Igray)/numel(Igray); imhist(Igray,32)/numel(Igray) 32 bins 256 bins Roger S. Gaborski

  13. Plots • bar(horz, v, width) • v is row vector • points to be plotted • horz is a vector same dimension as v • increments of horizontal scale • omitted  axis divided in units 0 to length(v) • width number in [0 1] • 1 bars touch • 0 vertical lines • 0.8 default Roger S. Gaborski

  14. p= imhist(Igray)/numel(Igray); >> h1 = p(1:10:256); >> horz = (1:10:256); >> figure, bar(horz,h1) Review other examples in text and in MATLAB documentation Roger S. Gaborski

  15. Chapter 3 www.prenhall.com/gonzalezwoodseddins Roger S. Gaborski

  16. Chapter 3 www.prenhall.com/gonzalezwoodseddins Roger S. Gaborski

  17. Color and Gray Scale ImagesRecall from Previous Slide Roger S. Gaborski

  18. Normalized Gray Scale Histogram >> p= imhist(Igray)/numel(Igray); >> figure, plot(p) probability Gray level values Roger S. Gaborski

  19. Gray Scale Histogram Roger S. Gaborski

  20. Normalized Gray Scale Histogram >> p= imhist(Igray)/numel(Igray); >> figure, plot(p) Roger S. Gaborski

  21. Normalized Gray Scale Histogram 256 bins 32 bins imhist(Igray)/numel(Igray); imhist(Igray,32)/numel(Igray) Roger S. Gaborski

  22. Normalized Gray Scale Histogram >> p= imhist(Igray)/numel(Igray); >> figure, plot(p) probability Gray level values Roger S. Gaborski

  23. Original Dark Light Roger S. Gaborski

  24. Contract enhancement • How could we transform the pixel values of an image so that they occupy the whole range of values between 0 and 255? Roger S. Gaborski

  25. Gray Scale Transformation • How could we transform the pixel values of an image so that they occupy the whole range of values between 0 and 255? • If they were uniformly distributed between 0 and x we could multiply all the gray level values by 255/x • BUT – what if they are not uniformly distributed?? Roger S. Gaborski

  26. Cumulative Distribution Function Histogram CDF Roger S. Gaborski

  27. Histogram Equalization(HE) • HE generates an image with equally likely intensity values • Transformation function: Cumulative Distribution Function (CDF) • The intensity values in the output image cover the full range, [0 1] • The resulting image has higher dynamic range • The values in the normalized histogram are approximately the probability of occurrence of those values Roger S. Gaborski

  28. Histogram Equalization • Let pr(rj), j = 1, 2, … , L denote the histogram associated with intensity levels of a given image • Values in normalized histogram are approximately equal to the probability of occurrence of each intensity level in image • Equalization transformation is: k = 1,2,…,L sk is intensity value of output rk is input value Sum of probability up to k value Roger S. Gaborski

  29. Histogram Equalization Example • g = histeq(f, nlev) where f is the original image and nlev number of intensity levels in output image Roger S. Gaborski

  30. Original Image INPUT Roger S. Gaborski

  31. Transformation x255 Output Gray Level Value Input Gray Level Value Roger S. Gaborski

  32. Equalization of Original Image OUTPUT Roger S. Gaborski

  33. Roger S. Gaborski

  34. Roger S. Gaborski

  35. Histogram Equalization Input Image Output Image Roger S. Gaborski

  36. Adaptive Equalization • g = adapthisteq(f, parameters..) • Contrast-limited adaptive histogram equalization • Process small regions of the image (tiles) individually • Can limit contrast in uniform areas to avoid noise amplification • See Table 3.2 (p108) for parameters Roger S. Gaborski

  37. Adaptive Histogram Equalization Default, 8x8 tiles Roger S. Gaborski

  38. Adaptive Equalization Roger S. Gaborski

  39. Chapter 3 www.prenhall.com/gonzalezwoodseddins Roger S. Gaborski

  40. Chapter 3 www.prenhall.com/gonzalezwoodseddins Roger S. Gaborski

  41. Create a ‘color image’ First create three color planes of data >> red = rand(5) red = 0.0294 0.0193 0.3662 0.7202 0.0302 0.7845 0.3955 0.2206 0.4711 0.2949 0.7529 0.1159 0.6078 0.9778 0.5959 0.1586 0.1674 0.5524 0.9295 0.1066 0.7643 0.6908 0.3261 0.5889 0.1359 >> green = rand(5) green = 0.2269 0.5605 0.6191 0.0493 0.1666 0.0706 0.4051 0.3297 0.7513 0.6484 0.9421 0.0034 0.8243 0.7023 0.8097 0.8079 0.5757 0.6696 0.9658 0.8976 0.0143 0.3176 0.6564 0.1361 0.0754 >> blue = rand(5) blue = 0.6518 0.0803 0.8697 0.6260 0.9642 0.5554 0.2037 0.8774 0.5705 0.6043 0.8113 0.8481 0.5199 0.0962 0.8689 0.5952 0.2817 0.6278 0.7716 0.8588 0.5810 0.9290 0.2000 0.1248 0.7606 Roger S. Gaborski

  42. colorIm(:,:,1) = 0.0294 0.0193 0.3662 0.7202 0.0302 0.7845 0.3955 0.2206 0.4711 0.2949 0.7529 0.1159 0.6078 0.9778 0.5959 0.1586 0.1674 0.5524 0.9295 0.1066 0.7643 0.6908 0.3261 0.5889 0.1359 colorIm(:,:,2) = 0.2269 0.5605 0.6191 0.0493 0.1666 0.0706 0.4051 0.3297 0.7513 0.6484 0.9421 0.0034 0.8243 0.7023 0.8097 0.8079 0.5757 0.6696 0.9658 0.8976 0.0143 0.3176 0.6564 0.1361 0.0754 colorIm(:,:,3) = 0.6518 0.0803 0.8697 0.6260 0.9642 0.5554 0.2037 0.8774 0.5705 0.6043 0.8113 0.8481 0.5199 0.0962 0.8689 0.5952 0.2817 0.6278 0.7716 0.8588 0.5810 0.9290 0.2000 0.1248 0.7606 >> colorIm(:,:,1)=red; >> colorIm(:,:,2)=green; >> colorIm(:,:,3)=blue; >> colorIm figure imshow(colorIm, 'InitialMagnification', 'fit') Roger S. Gaborski

  43. colorIm colorIm(1,1,: ) colorIm(4,4,: ) Roger S. Gaborski

  44. colorIm(:,:,1) = 0.0294 0.0193 0.3662 0.7202 0.0302 0.7845 0.3955 0.2206 0.4711 0.2949 0.7529 0.1159 0.6078 0.9778 0.5959 0.1586 0.1674 0.5524 0.9295 0.1066 0.7643 0.6908 0.3261 0.5889 0.1359 colorIm(:,:,2) = 0.2269 0.5605 0.6191 0.0493 0.1666 0.0706 0.4051 0.3297 0.7513 0.6484 0.9421 0.0034 0.8243 0.7023 0.8097 0.8079 0.5757 0.6696 0.9658 0.8976 0.0143 0.3176 0.6564 0.1361 0.0754 colorIm(:,:,3) = 0.6518 0.0803 0.8697 0.6260 0.9642 0.5554 0.2037 0.8774 0.5705 0.6043 0.8113 0.8481 0.5199 0.0962 0.8689 0.5952 0.2817 0.6278 0.7716 0.8588 0.5810 0.9290 0.2000 0.1248 0.7606 Roger S. Gaborski

  45. What are two methods to convert from a color image to a gray scale image? Roger S. Gaborski

  46. RECALL • What are two methods to convert from a color image to a gray scale image? • Average red, green and blue pixels Roger S. Gaborski

  47. Averaging • For example: >> colorImAverage = ( colorIm(:,:,1) + colorIm(:,:,2) + colorIm(:,:,3) )/3 colorImAverage = 0.3027 0.2200 0.6183 0.4651 0.3870 0.4701 0.3348 0.4759 0.5976 0.5159 0.8354 0.3224 0.6507 0.5921 0.7582 0.5206 0.3416 0.6166 0.8890 0.6210 0.4532 0.6458 0.3942 0.2833 0.3240 >> figure, imshow(colorImAverage, 'InitialMagnification', 'fit') Roger S. Gaborski

  48. Gray scale version of color image .5976 .5921 Roger S. Gaborski

  49. Color and Gray scale Images Roger S. Gaborski

  50. Color and Gray scale Images Conversion to gray scale results in a loss of information Roger S. Gaborski

More Related