1 / 61

2.3.2 Contrast Stretching

2.3.2 Contrast Stretching. Contrast The contrast of an image is its distribution of light and dark pixels. Fig. 2.12 Low and high contrast histogram. Contrast Stretching. Contrast stretching Clipping thresholding. Contrast Stretching. Contrast Stretching, a = 80, b= 160. Original Image.

Download Presentation

2.3.2 Contrast Stretching

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. 2.3.2 Contrast Stretching • Contrast • The contrast of an image is its distribution of light and dark pixels Fig. 2.12 Low and high contrast histogram.

  2. Contrast Stretching • Contrast stretching • Clipping • thresholding

  3. Contrast Stretching Contrast Stretching, a = 80, b= 160

  4. Original Image Basic Contrast Stretching Original Image End-in Search Contrast Stretching

  5. Contrast Stretching Original Image Convert Image

  6. Red Green Blue

  7. /******************************************** • * Func: auto_contrast_stretch • * Desc: performs basic contrast stretching on an image • * Params: source - pointer to source image • * cols - number of columns in the image * rows - height of image * • ********************************************* • void auto_contrast_stretch(image_ptr source, int cols, int rows) • { • long i; /* loop variable */ • long number_of_pixels; /* total number of pixels in image */

  8. long histogram[256]; /* image histogram */ • unsigned char LUT[256]; /* Look-up table for point process */ • int lowthresh, highthresh; /* lower and upper thresholds */ • float scale_factor; /* scaling factor for contrast stretch */ • /* compute histogram */ • number_of_pixels = (long)cols * rows; • for(i=0; i<256; i++) • histogram[i]=0; • for(i=0; i<number_of_pixels; i++) • histogram[source[i]]++;

  9. /* compute low and high thresholds */ • for(i=0; i<256; i++) • if(histogram[i]) { • lowthresh = i; • break; • } • for(i=255; i>0; i--) • if(histogram[i]) { • highthresh = i; • break; • }

  10. printf("Low threshold is %d High threshold is %d\n", • lowthresh,highthresh); • /* compute new LUT */ • for(i=0; i<lowthresh; i++) • LUT[i]=0; • for(i=255; i>highthresh; i--) • LUT[i]=255;

  11. scale_factor = 255.0 / (highthresh-lowthresh); • for(i=lowthresh; i<=highthresh; i++) • LUT[i]=(unsigned char)((i - lowthresh) * scale_factor); • /* transfer new image */ • for(i=0; i<number_of_pixels; i++) • source[i] = LUT[source[i]]; • }

  12. 2.3.3 Intensity transformations • Digital negative • Applications • Display of medical images • Produce negative prints of images • Intensity level slicing • Applications : • Segmentation of certain gray level regions

  13. Intensity transformations • Intensity transformation • Convert an old pixel into a new pixel based on some predefined function • Implemented with simple look-up tables • Simple transformation • Null transform • new pixel = old pixel • Image negative • y = -x+255 • Gamma correction function • Brightness of an image can be adjusted with a gamma correction transformation

  14. Intensity transformations • Posterizing • reduces the number of gray levels in an images • Thresholding results when number of gray levels is reduced to 2. • A bounced threshold reduces the thresholding to a limited range and treats the other input pixels as null transformation • Figure 2.18(pp.63) Fig. 2.18 (a) 8-Level posterize transformation; (b) posterized image; (c) threshold transformation; (d) threshold image; (e) bounded threshold; (f) bounded threshold image.

  15. Original gamma=0.45 gamma=2.20 Intensity transformations • Gamma correction

  16. Intensity Transformation • Intensity Transformation • Intensity transformation is a point process that converts an old pixel into a new pixel base on some predefined function. This transformation is implemented with the LUT with ease. • Gamma Correction

  17. Intensity Transformation

  18. Intensity Transformation

  19. Intensity Transformation

  20. Intensity transformations Fig. 2.16 (a) Gamma collection transformation with gamma=0.45; (b) gamma collected image; (c) gamma collection transformation with gamma=2.2; (d) gamma collected image. Fig. 2.15 (a) Null transformation; (b) image; (c) negative transformation; (d) negative image. Page 60. 참조

  21. Intensity transformations Fig. 2.17 (a) Contrast stretch transformation; (b) contrast stretched image; (c) Contrast compression transformation; (d) contrast compressed image. Fig. 2.18 (a) 8-Level posterize transformation; (b) posterized image; (c) threshold transformation; (d) threshold image; (e) bounded threshold; (f) bounded threshold image. Page 62. 참조

  22. Intensity transformations Fig. 2.19 (a) 2-bit bit-clipping transformation; (b) resulting image. Fig. 2.21 (a) Iso-intensity contouring transformation; (b) contoured image. Fig. 2.20 Bit clipped image contrast stretched. Page 64. 참조

  23. Intensity tranformations Fig. 2.22 (a) Range-highlighting transformation; (b) resulting image. Fig. 2.23 (a) Solarize transformation using a threshold of 150; (b) solarize image. Page 65. 참조

  24. Fig. 2.24 (a) First parabola transformation; (b) transformed image; (c) second parabola transformation; (d) second transformed image.

  25. HW – 03 a) Plot กราฟ histogram

  26. HW – 03 b)

  27. สจพ 2.4 Frequency-based Operations Fourier Transform DI&SP MTCT

  28. Spatial Frequency • Efficient data representation • Provides a means for modeling and removing noise • Physical processes are often best described in “frequency domain” • Provides a powerful means of image analysis

  29. What is spatial frequency? • Instead of describing a function (i.e., a shape) by a series of positions • It is described by a series of cosines • Fourier series • Fourier Transform

  30. สจพ 1-D Fourier Transform DI&SP MTCT

  31. Our starting place is the observation that a periodic function may be written as the sum of sines and cosines of varying amplitudes and frequencies.

  32. it is possible to form any function as a summation of a series of sine and cosine terms of increasing frequency • For example, in figure we plot a function, and its decomposition into sine functions.

  33. f(t)

  34. We take the first three terms only (blue, green, red) to provide the approximation of the original function (purple). • The more terms of the series we take, the closer the sum will approach the original function.

  35. Original function (purple) sines and cosines (1) where (2) Fourier coefficient Equations 1 and 2 are called Fourier transform pairs, and they exist if f(t) is continuous and integrable, and F(k) is integrable. These conditions are usually satisfied in practice.

  36. f(t) => time-domain I 1 2 3 4 1 F(u) => frequency-domain 3 II 4 2

  37. Any function can be represented in 2formats: • 1) time-domain representation, f(t), or spatial domain, f(x), and • 2) frequency-domain representationor Fourier domain, F(u) • In other words, any space ortime varying data can be transformed into a different domain called the frequencyspace.

  38. Time-domain Frequency-domain

  39. FT properties: If F(u) and G(u)are FT of function f(t) and g(t), respectively, • Time scaling • Frequency scaling

  40. Time shifting • Frequency shifting

  41. Convolution theorem • Correlation theorem

  42. สจพ 2-D Fourier Transform DI&SP MTCT

  43. แนวความคิดของการแปลงฟูเรียร์สามารถนำมาใช้กับฟังก์ชั่นหรือสัญญาณ 2 มิติ เช่น ภาพ ซึ่งจะเป็นการแปลงฟังก์ชั่นบน spatial domain (รูปภาพ) ไปเป็น frequency domain สมการคณิตศาสตร์แสดงความสัมพันธ์นี้เป็นดังนี้ IFT FT

  44. ภาพแสดงความสัมพันธ์ระหว่างภาพใน spatial domain และความถี่ใน frequency (or Fourier) domain

  45. พบว่าระยะถี่-ห่างทางตำแหน่งในภาพ (x-y ใน spatial domain) จะแปลงไปเป็นจุดใน frequency domain(u-v) • โดยบริเวณที่มีระยะห่าง (ซึ่งมีความถี่ทางตำแหน่งต่ำ) เช่น บริเวณตัวบ้านรวมทั้งหน้าต่าง-ประตู จะไปอยู่ในตำแหน่งที่ใกล้จุดกำเนิด • และในทางกลับกันบริเวณที่มีระยะถี่ (ซึ่งมีความถี่ทางตำแหน่งสูง) เช่น บริเวณที่มีลวดลายบนหลังคาบ้าน จะไปอยู่ในตำแหน่งที่ไกลจุดกำเนิดออกไป

More Related