Digital Image Processing: Image Enhancement - Duong Anh Duc presents about Image Enhancement; Point Operations; Image Negative; Contrast Stretching; Compression of Dynamic Range; Image Averaging for noise reduction; Some Averaging Filters; Some Typical Histograms.
Digital Image Processing Image Enhancement 21/11/15 Duong Anh Duc - Digital Image Processing Image Enhancement To process an image so that output is “visually better” than the input, for a specific application Enhancement is therefore, very much dependent on the particular problem/image at hand Enhancement can be done in either: – Spatial domain: operate on the original image g(m,n) = T[f(m,n)] – Frequency domain: operate on the DFT of the original image G(u,v) = T[F(u,v)], where F(u,v) = F[f(m,n)], and G(u,v) = F [g(m,n)], 21/11/15 Duong Anh Duc - Digital Image Processing Image Enhancement Techniques Point Operations • • • • • • • Image Negative Contrast Stretching Compression of dynamic range Graylevel slicing Image Subtraction Image Averaging Histogram operations 21/11/15 Mask Operations • • • • • Smoothing operations Median Filtering Sharpening operations Derivative operations Histogram operations Transform Operations Coloring Operations • • • • • • • Low pass Filtering Hi pass Filtering Band pass Filtering Homomorphic Filtering Histogram operations Duong Anh Duc - Digital Image Processing False Coloring Full color Processing Point Operations Output pixel value g(m, n) at pixel (m, n) depends only on the input pixel value at f(m, n) at (m, n) (and not on the neighboring pixel values) We normally write s = T(r), where s is the output pixel value and r is the input pixel value T is any increasing function that maps [0,1] into [0,1] 21/11/15 Duong Anh Duc - Digital Image Processing Image Negative T(r) = s = L-1-r, L: max grayvalue 21/11/15 Duong Anh Duc - Digital Image Processing Negative Image 21/11/15 Duong Anh Duc - Digital Image Processing Contrast Stretching Increase the dynamic range of grayvalues in the input image Suppose you are interested in stretching the input intensity values in the interval [r1, r2]: Note that (r1- r2) < (s1- s2) The grayvalues in the range [r1, r2] is stretched into the range [s1, s2] 21/11/15 Duong Anh Duc - Digital Image Processing Contrast Stretching Special cases: – Thresholding or binarization r1 = r2 , s1 = and s2 = – Useful when we are only interested in the shape of the objects and on on their actual grayvalues 21/11/15 Duong Anh Duc - Digital Image Processing Contrast Stretching 21/11/15 Duong Anh Duc - Digital Image Processing Contrast Stretching Special cases (cont.): – Gamma correction: S1 = 0, S2 = and 0, r g T r 21/11/15 r1 r r1 , r1 r r2 r1 1, r r2 r2 Duong Anh Duc - Digital Image Processing 10 Histogram Specification If the transformation zk G(zk) is one-toone, the inverse transformation sk G-1(sk), can be easily determined, since we are dealing with a small set of discrete grayvalues In practice, this is not usually the case (i.e., zk G(zk) is not one-to-one) and we assign grayvalues to match the given histogram, as closely as possible 21/11/15 Duong Anh Duc - Digital Image Processing 64 Ex.: Histogram Specification Consider the previous 8-graylevel 64 x 64 image histogram: rk nk p(rk)=nk/n k k 21/11/15 k k k 0 790 0.19 1/7 1023 0.25 2/7 850 0.21 3/7 656 0.16 4/7 329 0.08 5/7 245 0.06 6/7 122 0.03 81 0.02 Duong Anh Duc - Digital Image Processing 65 Ex.: Histogram Specification It is desired to transform this image into a new image, using a transformation z=H(r)= G-1[T(r)], with histogram as specified below: z p (z ) k k 21/11/15 out k 0 0.00 1/7 0.00 2/7 0.00 3/7 0.15 4/7 0.20 5/7 0.30 6/7 0.20 0.15 Duong Anh Duc - Digital Image Processing 66 Ex.: Histogram Specification The transformation T(r) was obtained earlier (reproduced below): ri s k p (s k) r0 s0 = 1/7 790 0.19 r1 s1 = 3/7 1023 0.25 r2 s2 = 5/7 850 0.21 985 0.24 448 0.11 r3,r4 s3 = 6/7 r5, r6,r7 21/11/15 nk s4=1 Duong Anh Duc - Digital Image Processing 67 Ex.: Histogram Specification Next we compute the transformation G as before G z0 pout zi pout z0 0.00 pout zi pout z0 pout z1 0.00 pout zi pout z0 pout z1 pout z pout zi pout z0 pout z1 pout z3 0.15 pout zi pout z0 pout z1 pout z 0.35 pout zi pout z0 pout z1 pout z5 0.65 pout zi pout z0 pout z1 pout z6 0.85 pout zi pout z0 pout z1 pout z7 1.00 i G z1 i G z2 0.00 i G z3 i G z4 i G z5 i G z6 i G z7 i 21/11/15 Duong Anh Duc - Digital Image Processing 68 7 7 Ex.: Histogram Specification Notice that G is not invertible But we will the best possible by setting G-1(0) = ? G-1(1/7) = 3/7 G-1(2/7) = 4/7 G-1(3/7) = 4/7 G-1(4/7) = ? G-1(5/7) = 5/7 G-1(6/7) = 6/7 G-1(1) = 21/11/15 (This does not matter since s 0) (This does not matter since s 2/7) (This is not defined, but we use a close match) (This does not matter since s 4/7) Duong Anh Duc - Digital Image Processing 69 Ex.: Histogram Specification Combining the two transformation T and G-1, we get our required transformation H r T(r)=s r0 = 1/7 r G-1 [T(r)]=H(r)=z r0 = z3= 3/7 r1 = 1/7 3/7 1/7 3/7 r1 = 1/7 z4= 4/7 r2 = 2/7 5/7 2/7 4/7 r2 = 2/7 z5= 5/7 r3 = 3/7 6/7 3/7 4/7 r3 = 3/7 z6= 6/7 r4 = 4/7 6/7 ? r4 = 4/7 z6= 6/7 4/7 r5 = 5/7 5/7 5/7 r5 = 5/7 z 7= r6 = 6/7 6/7 6/7 r6 = 6/7 z 7= r7 = 21/11/15 s G-1(s)=z ? 1 Duong Anh Duc - Digital Image Processing r7 = z7 = 70 Ex.: Histogram Specification Applying the transformation H to the original image yields an image with histogram as below: 21/11/15 k zk nk nk/n (actual hist.) pout(zk) (spec hist.) 1/7 2/7 3/7 4/7 5/7 6/7 0 790 1023 850 985 448 0.00 0.00 0.00 0.19 0.25 0.21 0.24 0.11 0.00 0.00 0.00 0.15 0.20 0.30 0.20 0.15 Duong Anh Duc - Digital Image Processing 71 Ex.: Histogram Specification 21/11/15 Duong Anh Duc - Digital Image Processing 72 Ex.: Histogram Specification Again, the actual histogram of the output image does not exactly but only approximately matches with the specified histogram This is because we are dealing with discrete histograms 21/11/15 Duong Anh Duc - Digital Image Processing 73 Example Original image and its histogram 21/11/15 Duong Anh Duc - Digital Image Processing 74 Example Histogram equalized image 21/11/15 Actual histogram of output Duong Anh Duc - Digital Image Processing 75 Example Histogram specified image, Actual Histogram, and Specified Histogram 21/11/15 Duong Anh Duc - Digital Image Processing 76 Enhancement Using Local Histogram Used to enhance details over small portions of the image Define a square or rectangular neighborhood, whose center moves from pixel to pixel Compute local histogram based on the chosen neighborhood for each point and apply a histogram equalization or histogram specification transformation to the center pixel Non-overlapping neighborhoods can also be used to reduce computations But this usually results in some artifacts (checkerboard like pattern) 21/11/15 Duong Anh Duc - Digital Image Processing 77 Enhancement Using Local Histogram Another use of histogram information in image enhancement is the statistical moments associated with the histogram (recall that the histogram can be thought of as a probability density function) For example, we can use the local mean and variance to determine the local brightness/contrast of a pixel This information can then be used to determine what, if any transformation to apply to that pixel Note that local histogram based operations are non-uniform in the sense that a different transformation is applied to each pixel 21/11/15 Duong Anh Duc - Digital Image Processing 78 ... 21/11/15 Duong Anh Duc - Digital Image Processing Image Negative T(r) = s = L-1-r, L: max grayvalue 21/11/15 Duong Anh Duc - Digital Image Processing Negative Image 21/11/15 Duong Anh Duc - Digital Image. .. =5 Duong Anh Duc - Digital Image Processing 24 Image Averaging Example M =10 21/11/15 Duong Anh Duc - Digital Image Processing M =25 25 Image Averaging Example M =50 21/11/15 Duong Anh Duc - Digital. .. 21/11/15 Duong Anh Duc - Digital Image Processing 22 Image Averaging Example Noise-free Image 21/11/15 Noisy Image Noise Variance = 0.05 Duong Anh Duc - Digital Image Processing 23 Image Averaging