Chapter 3 Image Enhancement in the Spatial Domain Yinghua He School o Computer Science and Technology Tianjin University
Image enhancement approaches Spatial domain image plane itsel Spatial domain methods Based on direct manipulation o pixels in an image. Frequency domain methods Based on modiying the Fourier transorm o an image
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
Spatial domain:the aggregate o pixels composing an image. Spatial domain methods: procedures that operate directly on these pixels. Spatial domain processes: denoted by the expression: [ ( x, )] g ( x, y) = T y (x,y):the input image g(x,y):the processed image T: an operator on, deined over some neighborhood o (x,y).
s = T (r) Gray-level transormation unction o the orm r: the gray level o (x,y) s: the gray level o g(x,y) Larger neighborhoods masks:is a small 2-D array. the mask coeicients determine the nature o the process, such as image sharpening. Masking processing Enhancement techniques based on this type o approach oten are reerred to as masking processing.
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
Three basic types o unctions used requently or image enhancement: Linear (negative and identity transormations) Logarithmic (log and inverse-log transormations) Power-law (nth power and nth root transormations)
Image negatives The negative o an image with gray levels in the range[0,l-1] is obtained by using the negative transormation in Fig. 3.3, which is given by the expression s=l-1-r
Log Transormations The general orm o the log transormation shown in Fig. 3.3 is s = c log( 1+ r) where c is a constant, and it is assumed that r>=0. This transormation maps a narrow range o low gray-level values in the input image into a wider range o output levels.
Power-Law Transormations Power-law transormations have the basic orm γ γ s = cr Where c and are positive constants.
2.5 s = s = r 1/ 2. 5 r
Piecewise-Linear Transormation Functions
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
Arithmetic/logic operations involving images are perormed on a pixel-by-pixel basis between two or more images. O the our arithmetic operations, subtraction and addition are the most useul or image enhancement. Masking sometimes is reerred to as region o interest(roi) processing.
Image subtraction Image Averaging
Image subtraction g( x, y) = ( x, y) h( x, y)
Image subtraction Image Averaging
Consider a noisy image g(x,y) ormed by the addition o noise to an original image (x,y); that is I an image is ormed by averaging K dierent noisy images, ), ( y x η ), ( ), ( ), ( y x y x y x g η + = ), ( y x g = = K i i y x g K y x g 1 ), ( 1 ), (
Then it ollows that And { g( x, y) } ( x, y) E = σ = 2 g ( x, y) 1 K σ 2 η ( x, y)
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
Some neighborhood operations work with the values o the image pixels in the neighborhood and the corresponding values o a subimage that gas the same dimensions as the neighborhood. The values in a ilter subimage are reerred to as coeicients, rather than pixels. For linear spatial iltering, the response is given by a sum o products o the ilter coeicients and the corresponding image pixels in the area spanned by the ilter mask.
The result, R, o linear iltering with the ilter mask at a point(x,y) in the image is R = w( 1, 1) ( x 1, y 1) + w( 1,0) ( x 1, y) +... + w(0,0) ( x, y) +... + w(1,0) ( x + 1, y) + w(1,1) ( x + 1, y + 1) In general, linear iltering o an image o size M*N with a ilter mask o size m*n is given by the expression: a b g ( x, y) = w( s, t) ( x + s, y + t) s= at= a
When interest lies on the response, R, o an m*n mask at any point(x,y), it is common pratice to simpliy the notation by using the ollowing expression: R = w1 z1 + w2 z 2 +... + w mn z mn = mn i= 1 w i z i
For the 3*3 general mask shown below, the response at any point(x,y) in the image is given by
I the center o the mask moves any closer to the border, one or more rows or columns o the mask will be located outside the image plane. There are several ways to handle this situations. To limit the excursions o the center o the mask to be at a distance no less than (n-1)/2 pixels rom the border. To ilter all pixels only with the section o the mask that is ully contained in the image. Padding the image by adding rows and columns o 0 s, or padding by replicating rows and columns.
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
Smoothing ilters are used or blurring and or noise reduction. Blurring is used in preprocessing steps, such as removal o small details rom an image prior to object extraction, and bridging o small gaps in lines or curves. Noise reduction can be accomplished by blurring with a linear ilter and also by non-linear iltering.
Smoothing Linear Filter Order-Statistics Filter
The output o a smoothing, linear spatial ilter is simply the average o the pixels contained in the neighborhood o the ilter mask. This ilters sometimes are called averaging ilters. They also reerred to a lowpass ilter.
The general implementation or iltering an M*N image with a weighted averaging ilter o size m*n is given by the expression = = 9 1 9 1 i z i R = = = = + + = a a s b b t a a s b b t t s w t y s x t s w y x g ), ( ), ( ), ( ), (
Smoothing Linear Filter Order-Statistics Filter
Order-statistics ilters are nonlinear spatial ilters whose response is based on ordering (rankng) the pixels contained in the image area encompassed by the ilter, and then replacing the value o the center pixel with the value determined by the ranking result. The best-known example in this category is the ilter, which, as its name implies, replaces the value o a pixel by the median o the gray levels in the neighborhood o that pixel.
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods
The principal objective o sharpening is to highlight ine detail in an image or to enhance detail that has been blurred, either in error or as a natural eect o a particular method o image acquisition. Averaging is analogous to integration; Sharpening could be accomplished by spatial dierentiation.
Foundation Use o Second Derivatives or Enhancement- The Laplacian Use o First Derivatives or Enhancement- The Gradient
We require that any deinition we use or a irst derivative. Must be zero in lat segments(areas o constant gray-level values); Must be nonzero at the onset o a gray-level step or ramp; Must be nonzero along ramps.
The deinition o a second derivative Must be zero in lat areas; Must be nonzero at the onset and end o a graylevel step or ramp; Must be zero along ramps o constant slope.
A basic deinition o the irst-order derivative o a one-dimensional unction (x) is the dierence. x = ( x + 1) ( x) We deine a second-order derivative as the dierence. 2 x 2 = ( x + 1) + ( x 1) 2 ( x)
Comparing the response between irst- and secondorder derivatives, we arrive at the ollowing conclusions. First-order derivatives generally produce thicker edges in an image. Second-order derivatives have a stronger response to ine detail, such as thin lines and isolated points. First-order derivatives generally have a stronger response to a gray level step. Second-order derivatives produce a double response at step changes in gray level.
Second-order derivatives that, or similar changes in gray-level values in an image, their response is stranger to a line than to a step, and to a point than to a line.
Foundation Use o Second Derivatives or Enhancement- The Laplacian Use o First Derivatives or Enhancement- The Gradient
We are interested in isotropic( 同向性 ) ilters, whose response is independent o the direction o the discontinuities in the image to which the ilter is applied. Isotropic ilters are rotation invariant.
The simplest isotropic derivative operator is the Laplacian, which, or a unction (image)(x,y) o two variables is deined as 2 2 2 = + 2 2 x y Because derivatives o any order are linear operations, the Laplacian is a linear operator.
We use the ollowing notation or the partial second-order derivative in the x-direction: And, similarly in the y-direction, as ), ( 2 ) 1, ( ) 1, ( 2 2 y x y x y x x + + = ), ( 2 1), ( 1), ( 2 2 y x y x y x y + + =
The digital implementation o the twodimensional Laplacian is obtained by summing these two components. [ ] ), ( 4 1), ( 1), ( ) 1, ( ) 1, ( 2 y x y x y x y x y x + + + + + =
Because the Laplacian is a derivative operator, its use highlights gray-level discontinuities in an image and deemphasizes regions with slowly varying gray levels. The basic way in which we use the Laplacian or image enhancement is as ollows: g( x, y) = ( x, ( x, y) y) + 2 2 ( x, ( x, y) y) i the center coeicient o Laplacian mask is negative i the center coeicient o Laplacian mask is positive the the
Simpliications [ ] [ ] 1), ( 1), ( ) 1, ( ) 1, ( ), ( 5 ), ( 4 1), ( 1), ( ) 1, ( ) 1, ( ), ( ), ( + + + + + = + + + + + + = y x y x y x y x y x y x y x y x y x y x y x y x g
Unsharp masking and highyboost iltering A process used or many years in the publishing industry to sharpen images consists o subtracting a blurred version o an image rom the image itsel. This process, called unsharp masking, is expressed as s ( x, y) = ( x, y) ( x, y) Where s ( x, y) denotes the sharpened image obtained by unsharp masking and ( x, y) is a blurred version o ( x, y).
A slight urther generalization o unsharp masking is called high-boost iltering. A highboost iltered image, hb, is deined at any point (x,y) as hb ( x, y) = A ( x, y) ( x, y) where A>=1 The equation may be written as hb ( x, y) = ( A 1) ( x, y) ( x, y) s
I we select to use the Laplacian, the above equation becomes 2 i the center coeicient o the A ( x, y) ( x, y) Laplacian mask is negative hb = 2 i the center coeicient o the A ( x, y) + ( x, y) Laplacian mask is positive When A=1, high-boost iltering becomes standard Laplacian sharpening.
For unction (x,y), the gradient o at coordinates (x,y) is deined as the twodimensional column vector The magnitude o this vector is given by = = y x G G y x [ ] 2 1 2 2 2 1 2 2 ) ( + = + = = y x G G mag y x
In order to reduce the computational burden, it is common practice to approximate the magnitude o the gradient by using absolute values instead o squares and square roots: G x + G y
The simplest approximations to a irst-order derivative that satisy the conditions stated are = z 8 z ) and = z 6 z ). G x ( 5 G y ( 5 The other deinitions proposed by Roberts in the early development o digital image processing use cross dierences: and = z 8 z G x = z 9 z ) ) ( 5 G y ( 6
We compute the gradient as or An approximation using absolute values, still at point, but using a 3*3 mask, is [ ] 2 1 2 6 8 2 5 9 ) ( ) ( z z z z + = 6 8 5 9 z z z z + z 5 ) 2 ( ) 2 ( ) 2 ( ) 2 ( 7 4 1 9 6 3 3 2 1 9 8 7 z z z z z z z z z z z z + + + + + + + + +
Sobel operators Roberts crossgradient operators
Outline Background Some Basic Gray Level Transormations Histogram Processing Enhancement Using Arithmetic/Logic Operations Basics o Spatial Filtering Smoothing Spatial Filters Sharpening Spatial Filters Combining Spatial Enhancement Methods