1 / 72

Introduction to Computer Vision

Introduction to Computer Vision. Lecture 3 Dr. Roger S. Gaborski. Quiz – Thursday Read Chapter 1 in textbook, p1-34 Chapter 2, p35-65 You are responsible for material in the textbook even if the material is not covered in lecture. Displaying Images [0, 255].

gaston
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 3 Dr. Roger S. Gaborski

  2. Quiz – Thursday • Read Chapter 1 in textbook, p1-34 • Chapter 2, p35-65 • You are responsible for material in the textbook even if the material is not covered in lecture. RS Gaborski

  3. Displaying Images [0, 255] • Consider we would like to display a gray level image that has a possible range of values 0-255 • When we display the image we can arrange for each gray level value to be displayed as a different light level on the display • Black would map to the gray level 0, white would map to the gray level 255. • Gray level values between 0 and 255 would map to shades of gray. RS Gaborski

  4. RECALL: Displaying Images [0,1] • The gray level of images can also be represented by real value numbers between 0 and 1. • 0 represents pixels that are black, 1 represents pixels that are white. • Values between 0 and 1 represent gray level values. RS Gaborski

  5. Range of Gray Level Values • The maximum range of values is [0,1] or [0,255] (for 8 bit images) • It is possible for images to use the maximum range of gray level values, or some subset • An image may only contain values between 0 and .6, or .3 and .9 RS Gaborski

  6. Image Types • Intensity images • When elements are class uint8 or uint16 they have integer values in the range [0 255] or [0 65535] • When elements are class double values are floating point numbers. Values are scaled in the range [0 1] by convention • Pixels with value 0.0 are displayed as black • Pixels with value 1.0 are displayed as white • Binary images • RGB images • Indexed images RS Gaborski

  7. Intensity Image >> I = imread('Flag1.jpg'); >> whos I Name Size Bytes Class Attributes I 320x240 76800 uint8 Image is of class uint8 >> >> max(I(:)) ans = 255 >> min(I(:)) ans = 0 Range 0 to 255 >> i = im2double(I); Convert to class double >> max(i(:)) ans = 1 >> min(i(:)) ans = 0 Range now 0 to 1 RS Gaborski

  8. Display image figure, imshow(i) RS Gaborski

  9. How is display affected if the range of pixel values is changed >> j = i*2 +1; >> min(j(:)) ans = 1 >> max(j(:)) ans = 3 >> figure, imshow(j) RS Gaborski

  10. imshow(j) RS Gaborski

  11. figure, imshow(j) RS Gaborski

  12. Image Types • Intensity images • Binary images • A logical array of 0s and 1s • An array of 0s and 1s that are of type uint8 is NOT a binary image • If A is a numeric array of 0s and 1s can create a logical array B using statement: B = logical(A) (all non zero values converted to 1s, entries with value 0 converted to logical 0s • RGB images • Indexed images RS Gaborski

  13. Binary Image >> BW = imread('circles.png'); >> whos BW Name Size Bytes Class Attributes BW 256x256 65536 logical >> imshow(BW) RS Gaborski

  14. Image Types • Intensity images • Binary images • RGB images • RGB color image is an MxNx3 array of color pixels • Each pixel is a triplet corresponds to the red, green and blue components at a specific spatial location • Can be interpreted as 3 planes of gray scale images fed into red, green and blue inputs of a color monitor • Class double, range of values [0,1] • Class uint8 or uint16 ranges are [0 255], [0 65535] • Indexed images RS Gaborski

  15. Chapter 2 – Fundamentals www.prenhall.com/gonzalezwoodseddins RS Gaborski

  16. Image Types • Intensity images • Binary images • RGB images • Indexed images • Two components: data matrix of integers, X, and a color map matrix, map • Map matrix is an mx3 array of class double floating point numbers in the range [0,1] • m is the number of colors defined for the image • Each row of m specifies the r,g and b components of a single color • Example: imshow(X,map) RS Gaborski

  17. Image Types • Indexed images • Indexed images use a direct mapping of pixel intensities to color map values • Color of each pixel is determined by using the corresponding values of integer matrix X as a pointer into map • If X is class uint8 or uint16 then all components with value 0 point to first row of map, value of 1 point to second row RS Gaborski

  18. Chapter 2 – Fundamentals www.prenhall.com/gonzalezwoodseddins RS Gaborski

  19. Image Enhancement • Brightness mapping • Contrast stretching/enhancement • Histogram modification • Noise Reduction • Mathematical Techniques • Convolution • Filtering • Edge and Line Detection and Extraction • Region Segmentation • Contour Extraction • Corner Detection • Higher Level Features RS Gaborski

  20. Intensity Transformation and Spatial Transformation • Intensity – modify each pixel in the image independently of its neighbors • Spatial – modify a pixel as a function of its neighbors (spatial convolution) RS Gaborski

  21. If you look at a pixel of an intensity (gray level image- Next Slide) in isolation what can you tell me about the image?

  22. RS Gaborski

  23. If you look at a pixel of an intensity (gray level image) in isolation what can you tell me about the image? The brightness or intensity value at that spatial location

  24. What if you inspect a neighborhood of pixel values?

  25. Depends on the neighborhood Sky Region Flag Region (2 rows, 3 columns) The ‘flag region’ contains more information about the image – There is a horizontal line in this region RS Gaborski

  26. Can we modify the intensity values to change the image (improve in some way) or extract information from the image (edges, shapes, etc.)? RS Gaborski

  27. Intensity Transformation and Spatial Transformation • The general spatial domain processing equation: g(x,y) = T[ f(x,y) ] • f(x,y) is the input image • g(x,y) is the output image • T is an operator on f defined over a specific neighborhood RS Gaborski

  28. Chapter 3 www.prenhall.com/gonzalezwoodseddins -Define spatial neighborhood about a point, (x,y) -Neighborhood is typically a square or rectangle, but could be other shapes -Center of neighborhood is moved from pixel to pixel starting at the upper left hand corner of the Image -Operator T is applied at each location (x,y) to yield g(x,y) at that location RS Gaborski

  29. Intensity Transformations • Let the neighborhood be reduced to a size of 1 x 1pixel • Now the transformation is only a function of the pixel itself. • This is commonly called an intensity transformation or gray level transformation function: s = T(r) where r is the intensity of f at (x,y) and s is the resulting intensity of g at (x,y) RS Gaborski

  30. Intensity Transformations • Assume the range of pixel intensity values is [0,1] • What can be accomplished with transformation T? RS Gaborski

  31. Intensity Transformations >> R = rand([1 4]) R = 0.0272 0.7937 0.9992 0.1102 >> R2 = R .* R ( note .* and not simply * ) R2 = 0.0007 0.6299 0.9985 0.0122 (small numbers are much smaller) >> RSR = sqrt(R) RSR = 0.1649 0.8909 0.9996 0.3320 RS Gaborski

  32. In this case the data is actually changed Not the display as in previous lecture RS Gaborski

  33. Intensity Transformations • Function imadjust • Intensity transformation of gray scale images • g = imadjust( f, [low_in high_in], [low_out, high_out], gamma) • Input - output defined in [0,1] range: • [low_in high_in]  [0 1] (min max) • [low_out high_out]  [0 1] (min max) RS Gaborski

  34. Chapter 3 www.prenhall.com/gonzalezwoodseddins Gamma specifies the shape of the curve Brighter Output Image Darker Output Image RS Gaborski

  35. >> I = imread('mammogram.tif'); >> figure, imshow(I) >> I2 = imadjust(I, [.5 .75], [0 1]); >> figure, imshow(I2) RS Gaborski

  36. Reduce the amount of tissue Mapped to black: >> I3 = imadjust(I, [.25 .75], [0 1]); >> figure, imshow(I3) RS Gaborski

  37. Output .25 .50 .75 1.0 I3 I2 .25 .50 .75 1.0 RS Gaborski

  38. Gamma=2 RS Gaborski

  39. Negative of image: >> I4 = imadjust(I,[0 1], [1 0]); >> figure, imshow(I4) Or I4 = imcomplement(I); RS Gaborski

  40. Logarithmic Transformation • g = log(f) where f is the input image • Issue: log(0) = -Inf • Any zeros in the input will be mapped to –Inf • Note: log(1) = 0 • g = log(1+f)  This ensures that log(f) is never mapped to –Inf • Similar to gamma transformation • Commonly used for dynamic range compression RS Gaborski

  41. Contrast Stretching Transformation • Compresses input values lower than m into a narrow range of dark levels • Compresses input values higher than m into a narrow range of light levels • Creates an image with higher contrast than the input image: • s = T(r) = 1 / ( 1+(m/r)E • r: intensities of input; s: intensities of output • m: threshold point (see graph) ; E: controls slope RS Gaborski

  42. Chapter 3 www.prenhall.com/gonzalezwoodseddins E controls the slope of the function RS Gaborski

  43. >>I = imread('mammogram.tif'); >> figure, subplot(2,2,1), imshow(I), title('I') >>E=1; >> g = 1./(1+(m./(double(I)+eps)).^E); >> subplot(2,2,2), imshow(g),title('E=1') >> E=3; >> g = 1./(1+(m./(double(I)+eps)).^E); >> subplot(2,2,3), imshow(g),title('E=3') >> E=5; >> g = 1./(1+(m./(double(I)+eps)).^E); >> subplot(2,2,4), imshow(g),title('E=5') RS Gaborski

  44. RS Gaborski

  45. Chapter 3 www.prenhall.com/gonzalezwoodseddins Input Output RS Gaborski

  46. 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 RS Gaborski

  47. Image Histogram Plot of Pixel Count as a Function of Gray Level Value RS Gaborski

  48. Histogram • Histogram consists of • Peaks- high concentration of gray level values • Valleys – low concentration • Flat regions RS Gaborski

  49. 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 RS Gaborski

  50. 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 RS Gaborski

More Related