Histogram Processing 1Image Enhancement:Histogram ProcessingReading: Chapter 3 (Spatial domain)Histogram Processing 2Histogram Processing• Histogram Equalization• Histogram Specification/MatchingHistogram Processing 3Histogramp(rk)= nk/nrkrk ∈ { 0, 1, 2, 3...., L−1} nk : # pixels with gray level rkn : # pixels in the imageHistogram Processing 4HistogramHistogram Processing 5Figure 3.15: histogramsHistogram Processing 6Histogram Modificationr : Input gray level ∈ [0, 1]s : Transformed gray level ∈ [0, 1]s = T (r) T : Transformation functionHistogram Processing 7Histogram Equalization ( i ) T (r) is single valued valued and monotonically increasing in 0 ! r ! 1 ( ii ) 0 ! T (r) ! 1 for 0 ! r ! 1 [0, 1]T" #" [0, 1] Inverse transformation : T$1(s)= r 0 ! s ! 1T$1(s) also satisfies ( i ) and ( ii )The gray levels in the image can be viewed as random variables takingvalues in the range [0,1].Let pr(r) : p.d.f. of input level r and let ps(s) : p.d.f. of ss = T (r) ; % ps(s) = pr(r) drdsr = T$1(s) (from ECE 140)Histogram Processing 8Equalization (contd.)We are interested in obtaining a transformation function T( )which transforms an arbitrary p.d.f. to an uniform distributionpr(r) ps(s)sHistogram Processing 9Consider s = T (r) = pr(w) dw 0 ! r ! 10r" (Cumulative distribution function of r)ps(s) = pr(r)drdsr = T#1(s );dsdr=ddrpr(w)dw0r"$%&'()= pr(r)* ps(s) = pr(r)1pr(r)r = T#1(s )+ 1 0 ! s ! 1Histogram Processing 10Equalization: Example 21rpr(r)pr(r) =!2r + 2 0 " r " 10 Else#$%s = T (r) = (2 ! 2w) dw0r&= (2w ! w2)0r= 2r ! r2'r2! 2 r + s = 0Histogram Processing 11Equalization (example: contd.)r =+2 ± 4 ! 4s2= 1 ± 1 ! sr = T!1(s) = 1 ! 1 ! s as r "[0,1]ps(s) = pr(r)drds= (!2r + 2)dds(1 ! 1 ! s)r =1! 1!s= (!2r + 2)!12(1 ! s)!1/ 2(!1)#$%&'(= (!2 + 2 1 ! s + 2)+12 1 ! s= 1 0 ) r ) 1Histogram Processing 12Equalized HistogramsHistogram Processing 13Fig 3.18: Transformation curvesHistogram Processing 14Equalization: Discrete Case 0 Number of levelsp rnnr k LLs T r p rnnr kkkk k r jjjkjk( ) ; , ,...,( ) ( )= ! ! = "#= = ===$$1 0 1 100Histogram Processing 15Discrete Case: Example64x64 image;8 gray levels.Notice thatequalizedhistogram isnotperfectly flat!k r nnnSnnp sssssssssk kkkjjksk=! !! !! !! !! !! !! !! !="0170173712757237673476735746747740 0 790 0 19 0 19 0 191 1023 0 25 0 0 252 850 0 21 0 65 0 213 656 0 16 0 81 0 244 329 0 08 0 89 0 245 245 0 06 0 95 1 0 116 122 0 03 0 98 1 0 117 81 0 02 1 0 1 0 11( ). . .. .44 .. . .. . .. . .. . .. . .. . .Histogram Processing 16Equalization: Image ExamplesOriginal, Equalized (64)Equalized (256)Histogram Processing 17..and their histogramsOriginal, equalized (64 levels)Equalized (256 levels)Histogram Processing 18Histogram specificationSuppose s = T (r) = pr(w) dw0r!pr(r) " Original histogram ; pz(z) " Desired histogramLet v = G(z) = pz(w)0z!dw and z = G#1(v)But s and v are identical p.d.f.$ z = G#1(v) = G#1(s) = G#1(T (r))Histogram Processing 19Question• What happens when you apply equalization to analready equalized histogram– In the continuous case?– In the discrete case?Histogram Processing 20Fig 3.19: MatchingHistogram Processing 21Matching: SummarySteps:(1) Equalize the levels of original image(2) Specify the desired pz(z) and obtain G(z)(3) Apply z=G-1(s) to the levels s obtained instep 1Histogram Processing 22Matching: an examplez p z v G r n p zzzzz sz sz sz szk z k k k k z k 0 0 0 0 0 0 0 0 0 0.15 = 790 0.19 0.35 = 1023 0.25 0.65 = 850 0.21 0.85 = 985 0.24 17375767( ) ( ) ( ).....===== != != != !=0117227337044715572667370 0000 150 20 30 21 0 154 1.0 = 1 448 0.11 ! sHistogram Processing 23Histogram Matching: exampleOriginal image(Jenolan caves,blue mountain,Sydney, Ausralia)Histogram Processing 24Color to grayscaleI=imread(‘sydney1.jpg);I1=rgb2gray(I);I1=imresize(I1,0.5);Imhist(I1);Histogram Processing 25Desired & modified histogramsI2=histeq(I1,imhist(J));Imhist(I2);Imhist(J)J=some imageHistogram Processing 26Histogram modified imageHistogram Processing 27Fig 3.20: Another exampleHistogram Processing 28Fig 3.21Histogram Processing 29Fig
View Full Document