Download presentation
Presentation is loading. Please wait.
Published byOliver Price Modified over 9 years ago
1
Manipulating contrast/point operations
2
Examples of point operations: Threshold (demo) Threshold (demo) Invert (demo) Invert (demo) Out[x,y] = max – In[x,y] RGB gray conversion RGB gray conversion Gamma correction Gamma correction Other methods Other methods histogram equalization histogram equalization color to gray color to gray scaling scaling
3
Gray to binary Thresholding Thresholding G B G B const int t=200; if (G[r][c]>t)B[r][c]=1; elseB[r][c]=0; How do we choose t? 1. Interactively 2. Automatically
4
Gamma correction
5
HISTOGRAM EQUALIZATION
6
Histogram equalization For many images we observe that it only uses a few different gray values. For many images we observe that it only uses a few different gray values. Often these gray values are close together. Often these gray values are close together.
7
Histogram equalization Histogram equalization goals: Histogram equalization goals: 1. Output image should use all gray values. 2. Output image has same number of pixels of each gray value. Which distribution is then preferred? (normal or uniform) Which distribution is then preferred? (normal or uniform) 3. (While maintaining the relationship (order) among gray values. - George’s rule.)
8
Histogram equalization from http://en.wikipedia.org/wiki/Histogram_equalization
9
Histo eq example (from http://www.cs.utah.edu/~jfishbau/improc/project2/images/crowd_hist_compare.png)
10
Histogram equalization Histogram equalization attempts to remap the input gray values to output gray values s.t. the histogram of the output achieves goals 1 and 2 (and 3) as best as possible. Histogram equalization attempts to remap the input gray values to output gray values s.t. the histogram of the output achieves goals 1 and 2 (and 3) as best as possible.
11
Histo eq example (from http://web2.clarkson.edu/class/image_process/qa1/Histogram%20Equalization%20Example_files/img92.gif)
12
Histogram Step 1: Estimate probability of a given gray value in an image. Step 1: Estimate probability of a given gray value in an image. h(g) = count of pixels w/ gray value equal to g. h(g) = count of pixels w/ gray value equal to g. histogram histogram p(g) = h(g) / (w*h) p(g) = h(g) / (w*h) w*h = # of pixels in entire image w*h = # of pixels in entire image Demo histogram. Demo histogram.
13
Histogram equalization Step 2: Estimate c.d.f. (cumulative distribution function). Step 2: Estimate c.d.f. (cumulative distribution function).
14
Histogram equalization Step 3: Use c.d.f. to map an input gray value g to “equalized” gray value, g’. Step 3: Use c.d.f. to map an input gray value g to “equalized” gray value, g’. Note: Since cdf(g) is in [0..1], we need to multiply by the max gray value so the result is in [0..max]. Note: Since cdf(g) is in [0..1], we need to multiply by the max gray value so the result is in [0..max]. Note: Calculate above only once for each gray value, save in a (lookup) table, and then let g’=lut[g]. Note: Calculate above only once for each gray value, save in a (lookup) table, and then let g’=lut[g].
15
Histogram equalization Only gray eq discussed so far. Only gray eq discussed so far. What about color? What about color? 1. Create 3 separate histograms for R, G, and B, and then equalize each individually (same as gray). 2. Better way is to convert RGB to color space with luminance (e.g., CIE XYZ, YIQ, YUV, HSL, or HSV), equalize luminance (same as gray), then convert back to RGB.
16
Histogram equalization algorithm Do Exercise 5.2 for homework. Do Exercise 5.2 for homework.
17
SCALING A RANGE OF GRAY VALUES
18
What about gray data that is less than 8 bits? Linearly map input [0,K] to [0,255]. Linearly map input [0,K] to [0,255].
19
What about gray data that is less than 8 bits? What if our minimum input value is something other than 0? What if our minimum input value is something other than 0?
20
What about gray data that is more than 8 bits? Linearly map input min to 0 and input max to 255. Linearly map input min to 0 and input max to 255. But we then compress (lose) our dynamic range, i.e., lose details. But we then compress (lose) our dynamic range, i.e., lose details. Map subranges of gray data to [0..255]. Map subranges of gray data to [0..255]. A.K.A. window width and level. A.K.A. window width and level.
21
from http://www.netterimages.com/images/vpv/000/000/061/61653-0550x0475.jpg
22
Window width and level Map subranges of gray data to [0..255]. Map subranges of gray data to [0..255]. A.K.A. window width and level. A.K.A. window width and level.
23
Window width and level Map subranges of gray data to [0..255]. Map subranges of gray data to [0..255]. A.K.A. window width and level. A.K.A. window width and level.
24
from https://www.imt.liu.se/people/dafor/visualization_files/image001.png
25
COLOR TO GRAY CONVERSION
26
Standard conversion from rgb to gray NTSC luminance NTSC luminance int luminance = (int)(0.30*r + 0.59*g + 0.11*b + 0.5); if (luminance<0)luminance = 0; if (luminance>255)luminance = 255; http://www.tektronix.com/Measurement/cgi- bin/framed.pl?Document=/Measurement/App_Note s/NTSC_Video_Msmt/colorbars.html&FrameSet=tel evision
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.