1 / 54

Introduction to Computer Vision

Introduction to Computer Vision. Lecture 4 Dr. Roger S. Gaborski. First Homework will be posted on the course webpage on Friday The problem will be due Tuesday at 10am Submit your results to (no hardcopy): rsg.introcv@gmail.com Details of what to submit is on the homework assignment page.

coty
Download Presentation

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. First Homework will be posted on the course webpage on Friday • The problem will be due Tuesday at 10am • Submit your results to (no hardcopy): rsg.introcv@gmail.com Details of what to submit is on the homework assignment page RS Gaborski

  3. 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

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

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

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

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

  8. Gamma=2 RS Gaborski

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

  10. 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

  11. 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

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

  13. >>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

  14. RS Gaborski

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

  16. 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

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

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

  19. 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

  20. 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: 1 maps to 0 2 maps to 1 3 maps to 2 4 maps to 3 5 maps to 4 RS Gaborski

  21. Normalized Histogram • Normalized histogram is obtained by dividing elements of h(rk) by the total number of pixels in the image (n): p(rk ) = h(rk) / n = nk /n for k = 1,2,..,L p(rk ) is an estimate of the probability of occurrence of intensity level rk RS Gaborski

  22. 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 • p = imhist( f, b ) / numel(f) RS Gaborski

  23. Gray Image >> I = imread('Flags.jpg'); >> figure, imshow(I) %uint8 >> Iint = mat2gray(I); %convert to double >> Igray = (Im(:,:,1)+Im(:,:,2)+Im(:,:,3))/3; >> figure, imshow(Igray) There is also the rgb2gray function that results in a slightly different image RS Gaborski

  24. rgb2gray First, convert to NTSC components: Y .299 .587 .114 R I = .596 -.274 -.322 G Q .211 -.523 .312 B Set I and Q components to zero, convert back to rgb: R 1.000 .956 .621 Y G = 1.000 -.272 -.647 I B 1.000 1.106 1.703 Q This will result in a gray image RS Gaborski

  25. Color and Gray Scale Images RS Gaborski

  26. Gray Scale Histogram RS Gaborski

  27. Normalized Gray Scale Histogram >> p= imhist(Igray)/numel(Igray); >> figure, plot(p) RS Gaborski

  28. Normalized Gray Scale Histogram 256 bins 32 bins imhist(Igray)/numel(Igray); imhist(Igray,32)/numel(Igray) RS Gaborski

  29. 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 • .8 default RS Gaborski

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

  31. Chapter 3 www.prenhall.com/gonzalezwoodseddins RS Gaborski

  32. Chapter 3 www.prenhall.com/gonzalezwoodseddins RS Gaborski

  33. Korean Text %readKorean.m image = imread('Korean1.jpg'); Convert to grayscale image image1 figure, imshow(image1) Gray scale image RS Gaborski

  34. Line Profile and Image1 Histogram Generate profile of text page at line 372 figure, plot(1:cols,image1(372,:)); RS Gaborski

  35. A Quick Look Ahead • Threshold image to obtain 0/1 pixels • Detect skew and rotate image • Segment characters • Label individual components of characters • Identify characters RS Gaborski

  36. Threshold • ImageThreshold = image>thresholdValue • Convert a double image with pixels in the range [0 1] to a binary image • Pixels have either a 0 or 1 value • The choice of thresholdValue in combination with quality of original image will determine binary image quality: • Broken characters • Filled in characters, such as, a, q, o, • Touching characters RS Gaborski

  37. Threshold = .7 SKEW RS Gaborski

  38. Image Rotation >> figure, imshow(imrotate(d,10)); RS Gaborski

  39. Segmentation of Korean Characters RS Gaborski

  40. Labeled Components of Korean Characters Input image Output image RS Gaborski

  41. Color and Gray Scale ImagesRecall from Previous Slide RS Gaborski

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

  43. How could we transform the pixel values of an image so that they occupy the whole range of values between 0 and 255? RS Gaborski

  44. 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?? RS Gaborski

  45. CUMULATIVE DISTRIBUTION FUNCTION Histogram CDF RS Gaborski

  46. Histogram Equalization • The histogram equalization transformation generates an image with equally likely intensity values • The intensity values in the output image cover the full range, [0 1] • The resulting image has higher dynamic range • Recall the values in the normalized histogram are approximately the probability of occurrence of those values • The histogram equalization transform is the cumulative distribution function (CDF) RS Gaborski

  47. 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: sk = T( rk ) =  pr(rj) =  nj / n k k k = 1,2,…,L sk is intensity value of output rk is input value j=1 j=1 Sum of probability up to k value RS Gaborski

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

  49. INPUT RS Gaborski

  50. Transformation x255 Output Gray Level Value Input Gray Level Value RS Gaborski

More Related