- 1. 1 UNIT-2 IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN Introduction to Image enhancement: Image enhancement is to process a given image so that the result is more suitable than the original image for a specific application. Objective of Image enhancement Principle objective of Image enhancement is to process an image so that result is more suitable than original image for specific application Image enhancement approaches fall into two broad categories: 1. Spatial domain methods 2. Frequency domain methods Spatial domain refers to the image plane itself, and approaches in this category are based on direct manipulation of pixels in an image. Frequency domain processing techniques are based on modifying the Fourier transform of an image.
- 2. 2 1. Spatial domain:- Spatial domain refers to the image plane itself, and approaches in this category are based on direct manipulation of pixels in an image. Spatial domain processes will be denoted by the expression g (x, y) = T [f (x, y)] Where, f(x, y) - input image, g(x, y) - processed image T - Operator on f, defined over some neighborhood of (x, y). The neighborhood about a point (x, y) is to use a square or rectangular sub image area centered at (x, y) Figure 1: 3*3 neighborhood about a point (x, y) in an image. The center of sub image is moved from pixel to pixel starting at the top left corner. The operator T is applied to each location (x,y) to find the output g at that location . The process utilizes only the pixel in the area of the image spanned by the neighborhood. Basic Gray Level Transformation Functions Here, T is a gray-level transformation function of the form: s = T(r) Where, r and s - denote the gray level of f(x, y) and g(x, y) at any point (x, y).
- 3. 3 (a) (b) Figure 2 a, b: Gray level transformation functions for contrast enhancement. Image enhancement can be done through gray level transformations which are discussed below. Intensity/ Gray Level Transformations: These are the simplest image enhancement techniques. 1. Linear (negative & Identity) transformation 2. Logarithmic (log & inverse) transformations 3. Power law(nth & nth root) transformations 4. Piecewise-Linear transformation functions 1. Linear transformation 1. Image Negative:- The negative of an image with gray levels in the range [0, L-1] is obtained by using the negative transformation. Where r= gray level value at pixel (x,y) L is the largest gray level consists in the image S = L – 1 - r
- 4. 4 i. If r=0, S = L – 1 ii. If r=L – 1, S = 0 Fig. Negative transformations This type of processing is particularly suited for enhancing white or gray detail embedded in dark regions of an image, especially when the black areas are dominant in size. 2. Logarithmic transformations Logarithmic transformation further contains two type of transformation. Log transformation and inverse log transformation. a) Log Transformations: The log transformations can be defined by this formula s = c log (1 + r) Where S and r are the pixel values of the output and the input image and c is a constant and it is assumed that r ≥ 0 During log transformation, the dark pixels in an image are expanded as compare to the higher pixel values. The higher pixel values are kind of compressed in log transformation. This result in following image enhancement The inverse log transformation is opposite to log transformation so will reduce low contrast image.
- 5. 5 3. Power-Law Transformations Power-law transformations have the basic form s = c ry Where c and γ are positive constants. Also can be represented as s = c (r+ε) y This symbol γ is called gamma We use gamma transformation where we need to expand or compress darker region i. If γ = 1, No change ii. If γ > 1, compresses dark values and expands bright values iii. If γ < 1, expands dark values Compresses bright values
- 6. 6 Power law curves with fractional values of y map a narrow range of dark input values into a wider range of output values, with the opposite being true for higher values of input gray levels. We may get various curves by varying values of y. Piecewise-Linear Transformations 1. Contrast Stretching It is the simplest piecewise linear transformation function The idea behind contrast stretching is to increase the dynamic range of gray levels in the image being processed. a) If r1=s1 and r2=s2, linear transformation b) If r1=r2 & s1=0, s2=L-1, thresholding c) Intermediate values of (r1, s1) and (r2, s2) produce various degrees of spread in the gray value
- 7. 7 2. Gray-level Slicing Gray level slicing is used to Highlighting a specific range of gray levels in an image. For example when enhancing features such as masses of water in satellite image and enhancing flaws in x- ray images. There are two methods of doing this- (1) One method is to display a high value for all gray level in the range of interest and a low value for all other gray level (2) Second method is to brighten the desired ranges of gray levels but preserve the background and gray level tonalities in the image.
- 8. 8 3. Bit-plane Slicing Highlighting the contribution made to total image appearance by specific bits might be desired. It is useful in image compression. Suppose that each pixel in an image is represented by 8 bits. Imagine that the image is composed of eight 1-bit planes, ranging from bit-plane 0 for the least significant bit to bit plane 7 for the most significant bit. In terms of 8-bit bytes, plane 0 contains all the lowest order bits in the bytes comprising the pixels in the image and plane 7 contains all the high-order bits. Example 1:- find the bit planes of given 3x3 image Solution:
- 9. 9 Example 2: find the bit planes of given 3x3 image Solution: binary representation of given image Histogram Processing The histogram of a digital image with gray levels in the range [0, L-1] is a discrete function h(rk)=nk Where rk is the kth gray level and nk is the number of pixels in the image having gray level rk. p(rk) is an estimate of the probability of occurrence of intensity level rk in an image.
- 10. 10 Histogram Equalization Histogram equalization is a technique for enhancing the appearance of images. Let us consider the transformations as, s=T(r), where 0 ≤ r ≤ 1 We assume that the transformation function T(r) satisfies the following conditions: a. T(r) is a monotonically increasing function in the interval 0 ≤ r ≤ L-1: b. 0 ≤ T(r) ≤ L-1 for 0 ≤ r ≤ L-1: Equalization automatically determines a transformation function that seeks to produce an output image that has a uniform histogram. It is a good approach when automatic enhancement is needed Histogram Equalization (Example)
- 11. 11 Solution: based on above table histogram of input image
- 12. 12
- 13. 13 Figure: Processed histogram So, that Input image output image Example:
- 15. 15 Question: Is histogram equalization always good? Ans: No
- 16. 16
- 18. 18 Basics of Spatial Filtering Filter term in “image processing” is referred to the subimage This sub image is called a filter, mask, kernel, template or window; The values in the filter sub image are referred to as coefficients rather than pixel. Spatial filtering operations are performed directly on the pixels values of the image The process consists of moving the filter mask from point to point in the image. The filter mask may be 3x3 mask or 5x5 mask or to be 7x7 mask. 1. Smoothing Spatial Filters: Smoothing filters are used for blurring and noise reduction in the image. Blurring is pre-processing steps for removal of small details and Noise Reduction is accomplished by blurring. Noise reduction can be accomplished blurring with a linear filter and also by non-linear filtering. Types of Smoothing Spatial Filter: There are two way of smoothing special filters 1. Smoothing Linear Filters: 2. Order Statistics Filters:- 1. Smoothing Linear Filter:- The output of a smoothing liner spatial filter is simply the average of the pixel contained in the neighborhood of the filter mask. These filters are also called averaging filters or low pass filters. A major application of smoothing is noise reduction.
- 19. 19 a) Averaging filter: A spatial averaging filter in which all coefficients are equal is sometimes referred to as a “box filter” Example: b) Weighted averaging filter: A weighted average filter is the one in which pixel are multiplied by different coefficients. Example: . 2. Order Statistics Filter:- Median filter In this filter the values of the center pixel is replaced by median of gray levels in the neighborhood of that pixel. Median filters are popular because, provide excellent noise-reduction capabilities, with less blurring than linear smoothing filters.
- 20. 20 These filters are particularly effective in the case of impulse or salt and pepper noise. Example Max filters This filter is useful for finding the brightest points in an image. Min filters This filter is useful for finding the darkest points in an image. Sharpening Filters: The principal objective of sharpening is to highlight fine details in an image
- 21. 21