This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Image Enhancement
Part 2 Arithmetic/Logic operations (e.g. subtraction, addition) perform on pixel by pixel basis between two or more images Except NOT operation which performs only on a single image Logic operation performs on graylevel images: Enhancement using Arithmetic/Logic Operations the pixel values are processed as binary numbers light represents a binary 1, dark represents a binary 0 Logic Operations Of the four arithmetic operations, substraction and addition are the most useful for image enhancement. AND and OR operations are used for masking; i.e. for selecting subimages in an image In enhancement process, masking is used to isolate an area for processing. Masking is also referred to as ROI (region of interest) processing. Example of AND Operation original image AND image mask result of AND operation Example of OR Operation original image OR image mask result of OR operation Image Subtraction The difference between 2 images f(x,y) and g(x,y) is expressed as follows: g(x,y) = f(x,y) h(x,y) a b d Image Subtraction c a). original fractal image b). result of discarding (setting to zero) the four least significant bit planes of the original image c). difference between (a) and (b) (nearly black shows so little differences in pixel values) d). histogram equalization of (c) (perform contrast stretching transformation in order to bring out detail in (c) the higher planes contribute significant detail the lower planes contribute more to fine detail (e.g. overall contrast due to less variability of the graylevel values in the image). Useful in Mask mode radiography the mask is an Xray image of a region of a patient's body captured by an intensified TV camera (instead of traditional Xray film) located opposite an Xray source On the right is an Xray image taken after injection iodine into the patient's bloodstream Note that the bright arterial paths carrying the medium are unmistakably The background is darker because it differences between areas of little enhanced. change yield low values (appear as dark shades of grays) mask image an image (taken after injection of a contrast medium (iodine) into the bloodstream) with mask subtracted out. They are bright because they are not subtracted out (i.e. they are not Image Enhancement Techniques Previously, we have looked into Gray Image Transformation, Histogram Processing and Logic Arithmetic Operators. Now, we moved into the Spatial Filters which includes the following:
Smooth Spatial Filters Sharpen Spatial Filters Spatial Filtering Neighborhood of a pixel p at position x,y is a set N(p) of pixels defined relative to p. P Q Spatial Filtering More examples of neighborhoods:
P P P P P P Spatial Filtering The most prominent neighborhoods are the 4Neighborhood and the 8Neighborhood P P Spatial Filtering use filter (can also be called as mask/kernel/template or window) the values in a filter subimage are referred to as coefficients, rather than pixel. Spatial Filtering Spatial Filtering Process simply move the filter mask from point to point in an image. at each point (x,y), the response of the filter at that point is calculated using a predefined relationship. R = w1 z1 + w2 z 2 + ... + wmn z mn = wi zi
i =i mn Smoothing Spatial Filters Average the values of the center pixel and its neighbours. The averaging process produce blurring effect Blurring reduces the high frequencies in an image (or increases the low frequencies) Purpose:
1. 2. 3. Reduction of `irrelevant' details Noise reduction Reduction of `false contours' (e.g. produced by Blurring & Noise Reduction blurring is used in preprocessing steps, such as:
removal of small details from an image prior to object extraction bridging of small gaps in lines or curves noise reduction can be accomplished by blurring with a linear filter and also by a nonlinear filter 1. Smoothing Linear Filters Also called as averaging filters or lowpass filters. Output is simply the average of the pixels contained in the neighborhood of the filter mask. Smoothing Linear Filters replacing the value of every pixel in an image by the average of the gray levels in the neighborhood will reduce the "sharp" transitions in gray levels. sharp transitions random noise in the image edges of objects in the image thus, smoothing can reduce noises (desirable) and blur edges (undesirable) 3x3 Smoothing Linear Filters box filter weighted average
the center is the most important and other pixels are inversely weighted as a function of their distance from the center of the mask General form : smoothing mask filter of size mxn (m and n odd) g ( x, y ) = s =  at =  b w(s, t ) f ( x + s, y + t )
s =  at =  b a b w(s, t ) a b summation of all coefficient of the mask Blurring using different radii (=size of neighborhood) a c e b d f a). original image 500x500 pixel b). f). results of smoothing with square averaging filter masks of size n = 3, 5, 9, 15 and 35, respectively. Note: big mask is used to eliminate small objects from an image. the size of the mask establishes the relative size of the objects Example original image we can see that the result after smoothing and thresholding, the remains are the largest and brightest objects in the image. result after smoothing with 15x15 averaging mask result of thresholding Smoothing Linear Filter Process With Box Filter
y
0 0 0 0 0 0 1/9 1/9 1/9 0 0 1/9 1/9 1/9 0 0 1/9 1/9 1/9 0 0 0 0 0 0 x I * ( x, y ) = I ( x, y ) * W ( x, y ) = u =  v =  I (u, v)W (u  x, v  y) Smoothing Linear Filter Process With Box Filter Grayscale Image:
1 2 5 3 4 6 11 10 1 4 3 3 6 0 2 2 10 9 2 9 9 0 7 8 10 Filter:
1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 Smoothing Linear Filter Process With Box Filter Original Image:
6 1/9 3 1/9 2 Filtered Image:
0 0 0 1 1/9 9 0 7 8 10 0 0 0 0 0 0 0 0 0 2 11 1/9 1/9 5 10 1/9 1/9 3 4 3 10 1/9 6 1/9 0 2 9 2 9 5 1 4 0 0 0 0 value = 1 1/9 + 6 1/9 + 3 1/9 + 2 1/9 + 11 1/9 + 3 1/9 + 5 1/9 + 10 1/9 + 6 1/9 = 47/9 = 5.222 Smoothing Linear Filter Process With Box Filter Original Image:
1 2 5 3 4 6 1/9 11 1/9 10 1/9 1 4 3 1/9 2 1/9 9 0 7 8 10 3 10 1/9 1/9 6 1/9 0 2 9 1/9 2 9 Filtered Image:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 7 value = 6 1/9 + 3 1/9 + 2 1/9 + 11 1/9 + 3 1/9 + 10 1/9 + 10 1/9 + 6 1/9 + 9 1/9 = 60/9 = 6.667 Smoothing Linear Filter Process With Box Filter Original Image:
6 11 10 1 4 3 3 6 0 2 2 10 9 2 9 Filtered Image:
0 0 0 5 5 6 0 1 2 5 3 4 9 0 7 8 10 0 0 0 0 0 0 0 0 0 0 5 5 4 0 7 6 5 0 Now you can see the averaging (smoothing) effect of the 3 that we applied. 3 filter Smoothing Linear Filter Process With Weighted Average Filter Filter
1 6 0 1 0 1 2 1 0 1 0 1 6 8 8 8 6 6 3 11 8 9 10 Input image: A 4x4, 4 bits/pixel Preprocessing: Zeropadding 9 10 10 7 0 1 6 8 8 8 6 6 0 0 0 0 0 3 11 8 9 10 0 1 6 8 0 0 8 8 0 0 6 0 6 0 0 0 0 0 3 11 8 9 10 0 0 0 9 10 10 7 9 10 10 7 Smoothing Linear Filter Process With Weighted Average Filter Move mask across the zeropadded image
1 6 0 1 0 1 2 1 0 1 0 0 0 0 0 0 0 0 1 6 8 0 0 8 8 0 0 6 0 6 0 0 0 0 0 3 11 8 9 10 0 0 0 Compute weighted sum Result:
2.6 4.3 6.2 4.3 4.0 6.5 8.0 7.2 6.5 7.7 9.5 7.3 6.0 7.8 7.7 5.7 9 10 10 7 round 3 4 7 6 4 7 8 6 8 8 4 7 6 8 10 7 2. OrderStatistics Filters (Nonlinear Filters Median Filters ) Nonlinear filters forces the points with distinct gray levels (impulses) to be more like their neighbors. replaces the value of a pixel by the median of the gray levels in the neighborhood of that pixel Median filtering is particularly effective when the noise pattern consists of strong, spikelike components. (Saltand pepper noise.) Reduces noise without blurring edges and other sharp details. n x n is the size of the mask Spatial Filtering
Original Salt&Pepper noise added 3x3 averagin g filter 3x3 median filter Example : Median Filters 34
Median Filter Use, for example, a 3 3 filter and move it across the image like we did before. For each position, compute the median of the brightness values of the nine pixels in question. To compute the median, sort the nine values in ascending order. The value in the center of the list (the fifth value) is the median. Use the median as the new value for the center pixel. Median Filter Median Filter 10 20 10 10 75 25 85 100 90 Sort: (10 10 10 20 25 75 85 90 100) Examples A 4x4 grayscale image is given by
5 0 5 5 6 6 6 7 7 7 8 8 8 impulse? impulse? 6 15 8 1) Filter the image with a 3x3 median filter, after zeropadding at the image borders
0 0 5 0 5 5 0 0 6 6 6 0 0 7 7 7 0 0 8 8 8 0 0 0 0 0 0 0 5 0 5 5 6 6 6 7 7 7 8 8 8 0 zeropadding 0 0 0 0 median filtering 0 5 5 0 5 6 6 5 6 7 7 6 0 7 7 0 6 15 8 6 15 8 Median Filter original image 3 3 median 7 7 median Median Filter Advantage of the median filter: Capable of eliminating outliers such as the extreme brightness values in saltandpepper noise. Disadvantage: The median filter may change the contours of objects in the image. Image Sharpening Deals with enhancing detail information in an image Detail information typically contained in the high frequency components of the image So, most techniques contain some form of highpass filtering Blurring vs. Sharpening Blurring in spatial domain is done by pixel averaging in a neighbors Sharpening is typically accomplished by spatial differentiation. Sharpening enhances the edges (high frequencies) in an image
41 Sharpening Spatial Filters to highlight fine detail in an image or to enhance detail that has been blurred, either in error or as a natural effect of a particular method of image acquisition. 42 Derivative operator thus, image differentiation enhances edges and other discontinuities (noise) deemphasizes area with slowly varying graylevel values. 43 Spatial Filtering Motivation: Derivatives Spatial Filtering First and second order derivative 1. 2. 3. 4. 1st order generally produces thicker edges 2nd order shows stronger response to detail 1st order generally response stronger to gray level step 2nd order produce double (pos&neg) response at step change 2nd derivative is better suited than the 1 st derivative for image enhancement because of its ability to enhance fine detail. Firstorder derivative a basic definition of the firstorder derivative of a onedimensional function f(x) is the difference f = f ( x + 1)  f ( x) x 46 Secondorder derivative similarly, we define the secondorder derivative of a onedimensional function f(x) is the difference f = f ( x + 1) + f ( x  1)  2 f ( x) 2 x
2
47 Spatial Filtering One dimensional 2nd derivative in x direction: F(x+1)F(x) (F(x)F(x1))= F(x+1)+F(x1)2F(x) 1 2 1 One dimensional 2nd derivative, direction y: 1 2 1 Discrete Form of Laplacian
from f = f ( x + 1, y ) + f ( x  1, y )  2 f ( x, y ) 2 x 2 f = f ( x, y + 1) + f ( x, y  1)  2 f ( x, y ) 2 y
2 yield, f = [ f ( x + 1, y ) + f ( x  1, y ) + f ( x, y + 1) + f ( x, y  1)  4 f ( x, y )]
2 Spatial Filtering TWO dimensional 2nd derivative: 0 1 0 0 2 0 0 1 0 0 1 2 1 0 0 0 0 1 4 1 0 1 0 + 0 0 = 1 0 This mask is called the `LAPLACIAN'
(remember calculus ?) Result Laplacian mask Spatial Filtering Different variants of the Laplacian masks Effect of Laplacian Operator as it is a derivative operator, it highlights graylevel discontinuities in an image it deemphasizes regions with slowly varying gray levels tends to produce images that have grayish edge lines and other discontinuities, all superimposed on a dark, Often referred to as featureless background. Correct the effect of featureless background By adding the original and Laplacian images. If the Laplacian filter used has a negative center coefficient, then we subtract, otherwise we add
if the center coefficient of the Laplacian mask is negative f ( x, y )  2 f ( x, y ) g ( x, y ) = f ( x, y ) + 2 f ( x, y ) Eq. (3.75) The basic way to use Laplacian for image enhancement is by the above Equation if the center coefficient of the Laplacian mask is positive Example (pg 130 Gonzalez) c) the grayish appearance is the typical of scaled Laplacian images d) add/subtract original image with the Laplacian. Laplacian restore the overall gray variations in the image & increasing the contrast at the locations of gray level discontinuities Net result = small details were enhanced, bckground tonality was preserved. Simplification: Mask of Laplacian + addition In the previous eg. Eq (3.75) is implemented by first computing the Laplacianfiltered image and then subtracting it from the original image. But, in practice, the Eq. is implemented with one pass of a single mask that performs both operations of Laplacian Filter and Addition the original image. Derive Composite Laplacian Mask
g ( x, y ) = f ( x, y )  [ f ( x + 1, y ) + f ( x  1, y ) + f ( x, y + 1) + f ( x, y  1) + 4 f ( x, y )] = 5 f ( x, y )  [ f ( x + 1, y ) + f ( x  1, y ) + f ( x, y + 1) + f ( x, y  1)]
0 1 0 1 5 1 0 1 0
If the diagonal neighbors were also included in the calculation of the Laplacian 1 1 1 1 9 1 1 1 1 f ( x, y )  f ( x , y ) g ( x, y ) = Note 2 f ( x, y ) + f ( x , y )
2 0 1 0 1 5 1 0 1 0 0 1 0 1 9 1 0 1 0 = 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 + 0 1 0 1 4 1 0 1 0 0 1 1 8 0 1 = + 0 0 0 0 1 0 Unsharp masking f s ( x, y ) = f ( x, y )  f ( x, y )
sharpened image = original image blurred image sharpened image = original image blurred image subtract a blurred version of an image to sharpening output image. A slight generalization of unsharp masking is called highboost filtering Highboost filtering Where A 1 f hb ( x, y ) = Af ( x, y )  f ( x, y )
Can also be written as follows: f hb ( x, y ) = ( A  1) f ( x, y ) + f ( x, y )  f ( x, y ) = ( A  1) f ( x, y ) + f s ( x, y )
This is the expression for computing highboostfiltered image
Refer to Unsharp Masking Equation Highboost filtering
f hb ( x, y ) = ( A  1) f ( x, y )  f s ( x, y )
This equation, however, does not state how the sharp image is obtained using highboost filter. So we applied Laplacian filter concept to create sharpen image fs(x,y) with additional A variable Highboost Masks A 1 if A = 1, it becomes "standard" Laplacian sharpening As the value of A increases past 1, the sharpening becomes less important, but overall increase in average gray level of the image, helps brighten the final result. Highboost filtering becomes important when the input image is darker than desired. if the center coefficient of the Laplacian mask is negative Af ( x, y )  f ( x, y ) f hb ( x, y ) = 2 Af ( x, y ) + f ( x, y )
2
if the center coefficient of the Laplacian mask is positive Gradient Mask Roberts crossgradient operators, 2x2 Gradient Mask Sobel operators, 3x3, are used as linefinders the weight value 2 is to achieve smoothing by giving more important to the center point Example Example of Combining Spatial Enhancement Methods want to sharpen the original image and bring out more skeletal detail. problems: 1. 2. narrow dynamic range of gray level and high noise content makes the image difficult to enhance Example of Combining Spatial Enhancement Methods solve : 1. 2. 3. Laplacian to highlight fine detail Gradient to enhance prominent edges Graylevel transformation to increase the dynamic range of gray levels Homework: Explain how linear spatial filtering is implemented in MATLAB. Explain how non linear spatial filtering (e.g. median filtering) is implemented in MATLAB. Find out how Laplacian mask is being used in MATLAB. ...
View Full
Document
 Winter '09
 NorAini

Click to edit the document details