870 likes | 1.84k Views
Digital Image Processing. Image Enhancement. 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.
E N D
Digital Image Processing Image Enhancement 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)], Duong Anh Duc - Digital Image Processing
Image Negative • Contrast Stretching • Compression of dynamic range • Graylevel slicing • Image Subtraction • Image Averaging • Histogram operations • Smoothing operations • Median Filtering • Sharpening operations • Derivative operations • Histogram operations • Low pass Filtering • Hi pass Filtering • Band pass Filtering • Homomorphic Filtering • Histogram operations • False Coloring • Full color Processing Duong Anh Duc - Digital Image 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]. Duong Anh Duc - Digital Image Processing
Image Negative T(r) = s = L-1-r, L: max grayvalue Duong Anh Duc - Digital Image Processing
Negative Image 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]. Duong Anh Duc - Digital Image Processing
Contrast Stretching • Special cases: • Thresholding or binarization r1 = r2 , s1 = 0 and s2 = 1 • Useful when we are only interested in the shape of the objects and on on their actual grayvalues. Duong Anh Duc - Digital Image Processing
Contrast Stretching Duong Anh Duc - Digital Image Processing
Contrast Stretching • Special cases (cont.): • Gamma correction: S1 = 0, S2 = 1 and Duong Anh Duc - Digital Image Processing
Contrast Stretching Gamma correction Duong Anh Duc - Digital Image Processing
Compression of Dynamic Range • When the dynamic range of the input grayvalues is large compared to that of the display, we need to “compress” the grayvalue range --- example: Fourier transform magnitude. • Typically we use a log scale. s = T(r) = c log(1+r) Duong Anh Duc - Digital Image Processing
Compression of Dynamic Range Saturn Image Mag. Spectrum Mag. Spectrum in log scale Duong Anh Duc - Digital Image Processing
Compression of Dynamic Range • Graylevel Slicing: Highlight a specific range of grayvalues. Duong Anh Duc - Digital Image Processing
Compression of Dynamic Range • Example: Highlighted Image (no background) Original Image Highlighted Image (with background) Duong Anh Duc - Digital Image Processing
Compression of Dynamic Range • Bitplane Slicing: Display the different bits as individual binary images. Duong Anh Duc - Digital Image Processing
Compression of Dynamic Range Duong Anh Duc - Digital Image Processing
Image Subtraction • In this case, the difference between two “similar” images is computed to highlight or enhance the differences between them: g(m,n) = f1(m,n)-f2(m,n) • It has applications in image segmentation and enhancement Duong Anh Duc - Digital Image Processing
Example: Mask mode radiography f1(m, n): Image before dye injection f2(m, n): Image after dye injection g(m, n): Image after dye injection, followed by subtraction Duong Anh Duc - Digital Image Processing
Image Averaging for noise reduction • Noise is any random (unpredictable) phenomenon that contaminates an image. • Noise is inherent in most practical systems: • Image acquisition • Image transmission • Image recording • Noise is typically modeled as an additive process: g(m,n) = f(m,n) + (m,n) Noise Noisy Image Noise-free Image Duong Anh Duc - Digital Image Processing
Image Averaging for noise reduction • The noise h (m, n) at each pixel (m, n) is modeled as a random variable. • Usually, h (m, n) has zero-mean and the noise values at different pixels are uncorrelated. • Suppose we have M observations {gi(m, n)}, i=1, 2, …, M, we can (partially) mitigate the effect of noise by “averaging” Duong Anh Duc - Digital Image Processing
Image Averaging for noise reduction • In this case, we can show that: • Therefore, as the number of observations increases (M ), the effect of noise tends to zero. Duong Anh Duc - Digital Image Processing
Image Averaging Example Noisy Image Noise Variance = 0.05 Noise-free Image Duong Anh Duc - Digital Image Processing
Image Averaging Example M =2 M =5 Duong Anh Duc - Digital Image Processing
Image Averaging Example M =10 M =25 Duong Anh Duc - Digital Image Processing
Image Averaging Example M =50 M =100 Duong Anh Duc - Digital Image Processing
Some Averaging Filters Duong Anh Duc - Digital Image Processing
Histograms • The histogram of a digital image with grayvalues r0, r1, …, rL-1 is the discrete function • The function p(rk) represents the fraction of the total number of pixels with grayvalue rk. • Histogram provides a global description of the appearance of the image. Duong Anh Duc - Digital Image Processing
Histograms • If we consider the grayvalues in the image as realizations of a random variable R, with some probability density, histogram provides an approximation to this probability density. In other words, Pr[R=rk] p(rk) Duong Anh Duc - Digital Image Processing
Some Typical Histograms • The shape of a histogram provides useful information for contrast enhancement. Duong Anh Duc - Digital Image Processing
Some Typical Histograms (cont.) • The shape of a histogram provides useful information for contrast enhancement. Duong Anh Duc - Digital Image Processing
Example: Histogram Stretching Duong Anh Duc - Digital Image Processing
Histogram Equalization • Idea: find a non-linear transformation g = T(f ) to be applied to each pixel of the input image f(x,y), such that a uniform distribution of gray levels in the entire range results for the output image g(x,y). Duong Anh Duc - Digital Image Processing
Histogram Equalization • Let us assume for the moment that the input image to be enhanced has continuous grayvalues, with r = 0 representing black and r = 1 representing white. • We need to design a grayvalue transformation s = T(r), based on the histogram of the input image, which will enhance the image. • As before, we assume that: • T(r)is a monotonically increasing function for 0r1 (preserves order from black to white) • T(r) maps [0,1] into [0,1] (preserves the range of allowed grayvalues). Duong Anh Duc - Digital Image Processing
Histogram Equalization Duong Anh Duc - Digital Image Processing
Histogram Equalization • Let us denote the inverse transformation by r = T-1(s). We assume that the inverse transformation also satisfies the above two conditions. • We consider the grayvalues in the input image and output image as random variables in the interval [0, 1]. • Let pin(r)and pout(s)denote the probability density of the grayvalues in the input and output images. Duong Anh Duc - Digital Image Processing
Histogram Equalization • If pin(r) and T(r) are known, and T-1(s) satisfies condition 1, we can write (result from probability theory): • One way to enhance the image is to design a transformation T(.) such that the grayvalues in the output is uniformly distributed in [0, 1], i.e. pout(s)=1, 0 s1 Duong Anh Duc - Digital Image Processing
Histogram Equalization • In terms of histograms, the output image will have all grayvalues in “equal proportion.” • This technique is called histogram equalization. • Consider the transformation Duong Anh Duc - Digital Image Processing
Histogram Equalization • Note that this is the cumulative distribution function (CDF) of pin(r) and satisfies the previous two conditions. • From the previous equation and using the fundamental theorem of calculus, Duong Anh Duc - Digital Image Processing
Histogram Equalization • Therefore, the output histogram is given by • The output probability density function is uniform, regardless of the input. Duong Anh Duc - Digital Image Processing
Histogram Equalization • Thus, using a transformation function equal to the CDF of input grayvalues r, we can obtain an image with uniform grayvalues. • This usually results in an enhanced image, with an increase in the dynamic range of pixel values. Duong Anh Duc - Digital Image Processing
Example: Histogram Equalization Original image Pout after histogram equalization Duong Anh Duc - Digital Image Processing
Example: Histogram Equalization Duong Anh Duc - Digital Image Processing
Histogram Equalization • For images with discrete grayvalues, we have • L: Total number of graylevels • nk: Number of pixels with grayvalue rk • n: Total number of pixels in the image Duong Anh Duc - Digital Image Processing
Histogram Equalization • The discrete version of the previous transformation based on CDF is given by: Duong Anh Duc - Digital Image Processing
Example • Consider an 8-level 64 x 64 image with grayvalues (0, 1, …, 7). The normalized grayvalues are (0, 1/7, 2/7, …, 1). The normalized histogram is given in the table: Duong Anh Duc - Digital Image Processing
Example(cont.) Duong Anh Duc - Digital Image Processing
Example(cont.) • Applying the previous transformation, we have (after rounding off to nearest graylevel): • Notice that there are only five distinct graylevels --- (1/7, 3/7, 5/7, 6/7, 1) in the output image. We will relabel them as (s0, s1, …, s4). Duong Anh Duc - Digital Image Processing
Example(cont.) • With this transformation, the output image will have histogram Duong Anh Duc - Digital Image Processing
Example(cont.) • Note that the histogram of output image is only approximately, and not exactly, uniform. This should not be surprising, since there is no result that claims uniformity in the discrete case. Duong Anh Duc - Digital Image Processing