Manipulating contrast/point operations. Examples of point operations: Threshold (demo) Threshold...
-
Upload
oliver-price -
Category
Documents
-
view
227 -
download
0
Transcript of Manipulating contrast/point operations. Examples of point operations: Threshold (demo) Threshold...
Examples of point operations:Examples of point operations:
Threshold (demo)Threshold (demo) Invert (demo)Invert (demo)
Out[x,y] = max – In[x,y]Out[x,y] = max – In[x,y]RGB RGB gray conversion gray conversionGamma correctionGamma correctionOther methodsOther methods
histogram equalizationhistogram equalizationcolor to graycolor to grayscalingscaling
Gray to binaryGray to binary
ThresholdingThresholding G G B B
const int t=200;const int t=200;
if (G[r][c]>t)if (G[r][c]>t) B[r][c]=1;B[r][c]=1;
elseelse B[r][c]=0;B[r][c]=0;
How do we choose t?How do we choose t?1.1. InteractivelyInteractively
2.2. AutomaticallyAutomatically
Histogram equalizationHistogram equalization
For many images we observe that it For many images we observe that it only uses a few different gray only uses a few different gray values.values.
Often these gray values are close Often these gray values are close together.together.
Histogram equalizationHistogram equalization
Histogram equalization goals:Histogram equalization goals:1.1. Output image should use all gray Output image should use all gray
values.values.
2.2. Output image has same number of Output image has same number of pixels of each gray value.pixels of each gray value.
Which distribution is then preferred? Which distribution is then preferred? (normal or uniform)(normal or uniform)
3.3. (While maintaining the relationship (While maintaining the relationship (order) among gray values. - George’s (order) among gray values. - George’s rule.)rule.)
Histogram equalizationHistogram equalization
from from http://en.wikipedia.org/wiki/Histogram_equalizationhttp://en.wikipedia.org/wiki/Histogram_equalization
Histo eq exampleHisto eq example(from (from
http://www.cs.utah.edu/~jfishbau/improc/project2/images/crowd_hist_compare.png)http://www.cs.utah.edu/~jfishbau/improc/project2/images/crowd_hist_compare.png)
Histogram equalizationHistogram equalization
Histogram equalization attempts to Histogram equalization attempts to remap the input gray values to remap the input gray values to output gray values s.t. the histogram output gray values s.t. the histogram of the output achieves goals 1 and 2 of the output achieves goals 1 and 2 (and 3) as best as possible.(and 3) as best as possible.
Histo eq exampleHisto eq example(from http://web2.clarkson.edu/class/image_process/qa1/Histogram%20Equalization(from http://web2.clarkson.edu/class/image_process/qa1/Histogram%20Equalization
%20Example_files/img92.gif)%20Example_files/img92.gif)
HistogramHistogram
Step 1: Estimate probability of a given Step 1: Estimate probability of a given gray value in an image.gray value in an image.
h(g) = count of pixels w/ gray value h(g) = count of pixels w/ gray value equal to g.equal to g.histogramhistogram
p(g) = h(g) / (w*h)p(g) = h(g) / (w*h)w*h = # of pixels in entire imagew*h = # of pixels in entire image
Demo histogram.Demo histogram.
1..0 :Note gp
Histogram equalizationHistogram equalization
Step 2: Estimate c.d.f. (cumulative Step 2: Estimate c.d.f. (cumulative distribution function).distribution function).
g
i
gpgcdf0
1..0 :Note gcdf
Histogram equalizationHistogram equalization
Step 3: Use c.d.f. to map an input gray Step 3: Use c.d.f. to map an input gray value g to “equalized” gray value, g’.value g to “equalized” gray value, g’.
Note: Since cdf(g) is in [0..1], we need to Note: Since cdf(g) is in [0..1], we need to multiply by the max gray value so the result multiply by the max gray value so the result is in [0..max].is in [0..max].
Note: Calculate above only once for each Note: Calculate above only once for each gray value, save in a (lookup) table, and gray value, save in a (lookup) table, and then let g’=lut[g].then let g’=lut[g].
max*' gcdfg
Histogram equalizationHistogram equalization
Only gray eq discussed so far.Only gray eq discussed so far.What about color?What about color?
1.1. Create 3 separate histograms for R, G, Create 3 separate histograms for R, G, and B, and then equalize each and B, and then equalize each individually (same as gray).individually (same as gray).
2.2. Better way is to convert RGB to color Better way is to convert RGB to color space with luminance (e.g., CIE Xspace with luminance (e.g., CIE XYYZ, Z, YYIQ, YUV, HSIQ, YUV, HSLL, or HS, or HSVV), equalize ), equalize luminance (same as gray), then convert luminance (same as gray), then convert back to RGB.back to RGB.
Histogram equalization Histogram equalization algorithmalgorithm
Do Exercise 5.2 for homework.Do Exercise 5.2 for homework.
What about gray data that is What about gray data that is less than 8 bits? less than 8 bits?
Linearly map input [0,K] to [0,255].Linearly map input [0,K] to [0,255].
in
inout
out
out
in
in
max
255gg
max
g
max
g
What about gray data that is What about gray data that is less than 8 bits? less than 8 bits?
What if our minimum input value is What if our minimum input value is something other than 0?something other than 0?
inin
ininout
out
out
inin
inin
minmax
ming255g
max
g
minmax
ming
What about gray data that is What about gray data that is more than 8 bits? more than 8 bits?
Linearly map input min to 0 and Linearly map input min to 0 and input max to 255.input max to 255.But we then compress (lose) our But we then compress (lose) our
dynamic range, i.e., lose details.dynamic range, i.e., lose details.
Map subranges of gray data to Map subranges of gray data to [0..255].[0..255].A.K.A. window width and level.A.K.A. window width and level.
from http://www.netterimages.com/images/vpv/000/000/061/61653-from http://www.netterimages.com/images/vpv/000/000/061/61653-0550x0475.jpg0550x0475.jpg
Window width and levelWindow width and level
Map subranges of gray data to Map subranges of gray data to [0..255].[0..255].A.K.A. window width and level.A.K.A. window width and level.
useruser
userinout
out
out
useruser
userin
minmax
ming255g
max
g
minmax
ming
Window width and levelWindow width and level
Map subranges of gray data to Map subranges of gray data to [0..255].[0..255].A.K.A. window width and level.A.K.A. window width and level.
255g 255g
0g 0g
minmax
ming255g
outout
outout
useruser
userinout
if
if
from from https://www.imt.liu.se/people/dafor/visualization_files/image001.pnghttps://www.imt.liu.se/people/dafor/visualization_files/image001.png
Standard conversion from rStandard conversion from rggb to b to ggrayray
NTSC luminanceNTSC luminance
int luminance = (int)(0.30*r + 0.59*g + 0.11*b + int luminance = (int)(0.30*r + 0.59*g + 0.11*b + 0.5);0.5);
if (luminance<0)if (luminance<0) luminance = 0;luminance = 0;if (luminance>255)if (luminance>255) luminance = 255;luminance = 255;
http://www.tektronix.com/Measurement/cgi-http://www.tektronix.com/Measurement/cgi-bin/framed.pl?Document=/Measurement/bin/framed.pl?Document=/Measurement/App_Notes/NTSC_Video_Msmt/App_Notes/NTSC_Video_Msmt/colorbars.html&FrameSet=televisioncolorbars.html&FrameSet=television