image enhancement spatial domain

94
Resmi N.G. Reference: Digital Signal Processing Rafael C. Gonzalez Richard E. Woods

Upload: resming

Post on 21-Apr-2015

902 views

Category:

Documents


6 download

DESCRIPTION

CS804B, M2_1, Lecture Notes

TRANSCRIPT

Page 1: Image Enhancement Spatial Domain

Resmi N.G.Reference:

Digital Signal ProcessingRafael C. GonzalezRichard E. Woods

Page 2: Image Enhancement Spatial Domain

Overview� Spatial Domain Methods

� Point Processing� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)� Piece-wise Linear

� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Histogram Processing� Histogram Equalization� Histogram Matching or Histogram Specification

� Enhancement using Arithmetic/ Logic Operations� Image Subtraction� Image Averaging

3/20/2012 CS04 804B Image Processing - Module2 2

Page 3: Image Enhancement Spatial Domain

� Mask Processing /Filtering� Linear Spatial Filtering� Non-Linear Spatial Filtering� Smoothing Spatial Filters

� Smoothing Linear Filters� Box-Filter� Weighted Average Filter

� Order-Statistics Filters (Non-Linear Spatial Filters)� Median Filter� Median Filter� Max-filter� Min-filter

� Sharpening Spatial Filters� Second-Order Derivatives

� Laplacian� Unsharp Masking� High Boost Filtering and its Application

� First-Order Derivatives (Gradient)

3/20/2012 CS04 804B Image Processing - Module2 3

Page 4: Image Enhancement Spatial Domain

Image Enhancement� To process an image so that the result is more suitable

than the original image for a specific application.

� Two categories:� Two categories:� Spatial domain methods

� Direct manipulation of pixels

� Frequency domain methods� Modifying the Fourier Transform of an image.

3/20/2012 4CS04 804B Image Processing - Module2

Page 5: Image Enhancement Spatial Domain

� Spatial Domain Methods� Point Processing

� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)� Piece-wise Linear

� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Histogram Processing� Histogram Equalization� Histogram Matching or Histogram Specification

� Enhancement using Arithmetic/ Logic Operations� Image Subtraction� Image Averaging

3/20/2012 CS04 804B Image Processing - Module2 5

Page 6: Image Enhancement Spatial Domain

Spatial Domain Methods� Operates directly on pixels.

� Denoted by the expressiong(x,y) = T[f(x,y)]� g(x,y) = T[f(x,y)]

� where f(x,y) is the input image, g(x,y) is the processedimage, T is an operator on f defined over someneighbourhood of (x,y).

� T can also operate on a set of input images.

3/20/2012 6CS04 804B Image Processing - Module2

Page 7: Image Enhancement Spatial Domain

� Neighbourhood – square or rectangular sub-image area centred at (x,y).

� T is applied at each (x,y) to obtain output g at that location.

3/20/2012 7CS04 804B Image Processing - Module2

Page 8: Image Enhancement Spatial Domain

� Simplest form of T –� when neighbourhood is of size 1x1 (a single pixel).� g depends only on the value of f at (x,y)� s = T(r)

� Enhancement at any point in an image depends only on thegray level at that point (Point Processing or Gray-LevelTransformation).

� Larger neighbourhoods – Mask Processing or SpatialFiltering.

3/20/2012 8CS04 804B Image Processing - Module2

Page 9: Image Enhancement Spatial Domain

� Spatial Domain Methods� Point Processing

� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)� Piece-wise Linear

� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Histogram Processing� Histogram Equalization� Histogram Matching or Histogram Specification

� Enhancement using Arithmetic/ Logic Operations� Image Subtraction� Image Averaging

3/20/2012 CS04 804B Image Processing - Module2 9

Page 10: Image Enhancement Spatial Domain

Gray Level Transformations

� Three basic types:� Linear (Image Negatives and Identity)� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)

3/20/2012 10CS04 804B Image Processing - Module2

Page 11: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 11

Page 12: Image Enhancement Spatial Domain

Image Negatives

� The negative of an image with gray levels in the range[0,L-1] is obtained by using the transformation given by

� s = L-1-r� Reverses the intensity levels of an image.� For enhancing gray or white detail embedded in dark

regions of an image.

3/20/2012 CS04 804B Image Processing - Module2 12

Page 13: Image Enhancement Spatial Domain

Log Transformation� General form: s = c log(1+r)

where c is a constant and r ≥ 0.

� Maps a narrow range of low-level gray values in the inputimage into a wider range of output levels.image into a wider range of output levels.

� Maps a wide range of high-level gray values in the input imageinto a lower range of output levels.

� For expanding the values of dark pixels while compressinghigher-level values.

� Compresses the dynamic range of images with large variationsin pixel values.

3/20/2012 CS04 804B Image Processing - Module2 13

Page 14: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 14

Page 15: Image Enhancement Spatial Domain

Power-Law Transformation� Basic form:s = crγ

where c and γ are positive constants.� Power-law curves with fractional values of γ (γ <1)

produces similar effect as log transformation.produces similar effect as log transformation.� Power-law curves with γ >1 have exactly the opposite

effect as compared to those with γ <1.� When c = γ = 1, it reduces to identity transformation.

� Gamma correction-� General purpose contrast manipulation-

3/20/2012 CS04 804B Image Processing - Module2 15

Page 16: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 16

Page 17: Image Enhancement Spatial Domain

� Spatial Domain Methods� Point Processing

� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)� Piece-wise Linear

� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Histogram Processing� Histogram Equalization� Histogram Matching or Histogram Specification

� Enhancement using Arithmetic/ Logic Operations� Image Subtraction� Image Averaging

3/20/2012 CS04 804B Image Processing - Module2 17

Page 18: Image Enhancement Spatial Domain

Piecewise-Linear Transformations� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Advantage – Piecewise functions can be complex.� Disadvantage – Specification requires more user input.

3/20/2012 CS04 804B Image Processing - Module2 18

Page 19: Image Enhancement Spatial Domain

Contrast Stretching� Increases the dynamic range of gray levels in input

image.

� Causes for low contrast images:� Causes for low contrast images:� Poor illumination� Lack of dynamic range in imaging sensor� Wrong setting of lens aperture during image

acquisition.

3/20/2012 CS04 804B Image Processing - Module2 19

Page 20: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 20

Page 21: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 21

Page 22: Image Enhancement Spatial Domain

Gray-Level Slicing� Highlights a specific range of gray levels in an image.

� Approach 1 - Assigns a high value for all gray levels inthe range of interest and a low value for all other graythe range of interest and a low value for all other graylevels.

� Produces binary image.

� Approach 2 – Brightens the desired range of gray levelsbut preserves the background and gray-level tonalities inthe image.

3/20/2012 CS04 804B Image Processing - Module2 22

Page 23: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 23

Page 24: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 24

Page 25: Image Enhancement Spatial Domain

Bit-Plane Slicing� Highlights the contribution made to total image

appearance by specific bits.� Useful in analyzing the relative importance of each bit of� Useful in analyzing the relative importance of each bit of

the image.� Helps to determine the number of bits used to quantize

each pixel.� Useful for image compression.

3/20/2012 CS04 804B Image Processing - Module2 25

Page 26: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 26

Page 27: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 27

Page 28: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 28

Page 29: Image Enhancement Spatial Domain

� Spatial Domain Methods� Point Processing

� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)� Piece-wise Linear

� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Histogram Processing� Histogram Equalization� Histogram Matching or Histogram Specification

� Enhancement using Arithmetic/ Logic Operations� Image Subtraction� Image Averaging

3/20/2012 CS04 804B Image Processing - Module2 29

Page 30: Image Enhancement Spatial Domain

Histogram Processing� Contrast adjustment is done using histogram of an image.

� Intensities can be better distributed.

� Advantage – invertible; if histogram equalization functionis known, the original image can be recovered.

� Disadvantage – May increase the contrast of backgroundnoise.

3/20/2012 CS04 804B Image Processing - Module2 30

Page 31: Image Enhancement Spatial Domain

� Histogram Equalization� Automatically determines a transformation function to

produce image with a uniform histogram.

� Histogram Matching/ Histogram Specification� Produces an output image with a specified histogram.

3/20/2012 CS04 804B Image Processing - Module2 31

Page 32: Image Enhancement Spatial Domain

Histogram� 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.

� p(rk) is the probability of occurrence of gray level rk.

3/20/2012 CS04 804B Image Processing - Module2 32

Page 33: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 33

Page 34: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 34

Page 35: Image Enhancement Spatial Domain

� High contrast image � – histogram covers a broad range of the grayscale.� - distribution of pixels nearly uniform.� - distribution of pixels nearly uniform.� - exhibits large variety of gray tones.

3/20/2012 CS04 804B Image Processing - Module2 35

Page 36: Image Enhancement Spatial Domain

Histogram Equalization: ; [0,1]

: ; [0,1]

:

r gray level of input image r

s gray level of output image s

T Transformation function

� T(r) satisfies the conditions:a) T(r) is single-valued and monotonically increasing in the

interval 0 ≤ r ≤ 1.b) 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1.

3/20/2012 CS04 804B Image Processing - Module2 36

:

( );0 1

T Transformation function

s T r r= ≤ ≤

Page 37: Image Enhancement Spatial Domain

� Condition (a) that T(r) be single-valued guarantees that aninverse transformation exists.

� ( f(x) = x2 is non-invertible for domain of real numbers.)

� Invesre transformation from s to r:� r = T-1(s), 0 ≤ s ≤ 1

� Monotonicity condition preserves the increasing orderfrom black to white in the output image.

� Condition (b) guarantees that the output image gray levelswill be in the same range as the input levels.

3/20/2012 CS04 804B Image Processing - Module2 37

Page 38: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 38

Page 39: Image Enhancement Spatial Domain

1

( ) :

( ) :

( ) ( ) ( ) ( ),

( ) ( ) (1)

r

s

r

s r

p r probability density functionof r

p s probability density functionof s

If p r and T r are knownand T s satisfies a then

drp s p r

ds

= − − −

3/20/2012 CS04 804B Image Processing - Module2 39

0

( ) ( ) (1)

( ) ( ) (2)

s r

r

r

dsAtransformation functionhas the form

s T r p w dw

RHS is

= = − − −∫.thecumulativedistribution functionof r

Page 40: Image Enhancement Spatial Domain

( ), ( ) (1).

, ( )

( )

( )

s

r

r

GivenT r are known p s canbeobtained using

Weknow s T r

ds dT rdr dr

dp w dw

dr

=

=

=

3/20/2012 CS04 804B Image Processing - Module2 40

0

0

( )

( ) (3)

( ' : . . .

r

r

r

dr

dp w dw

dr

p r

Leibniz s rule derivativeof a definite integral w r t

its upper limit is theintegrand evaluat

=

= − − −

.)ed at that limit

Page 41: Image Enhancement Spatial Domain

(3) (1)

( ) ( )

1( )

( )

s r

r

Substituting in gives

drp s p r

ds

p rp r

=

=

3/20/2012 CS04 804B Image Processing - Module2 41

( )

1; 0 1

( ) :

.

( ).

r

s

r

p r

s

p s is therefore

always auniform probability density function

independent of p r

= ≤ ≤

Page 42: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 42

Page 43: Image Enhancement Spatial Domain

� Discrete Version:

(3) (1)

( ) , 0,1,..., 1

( ) ( )

kr k

k

Substituting in gives

np r k L

n

s T r p r

= = −

= =∑

3/20/2012 CS04 804B Image Processing - Module2 43

0

0

( ) ( )

, 0,1,..., 1

.

k k r jj

kj

j

s T r p r

nk L

n

This transformationis called histogramequalization

=

=

= =

= = −

Page 44: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 44

Page 45: Image Enhancement Spatial Domain

3/20/2012 45CS04 804B Image Processing - Module2

Page 46: Image Enhancement Spatial Domain

3/20/2012 46CS04 804B Image Processing - Module2

Page 47: Image Enhancement Spatial Domain

3/20/2012 47CS04 804B Image Processing - Module2

Page 48: Image Enhancement Spatial Domain

Histogram Matching� To generate an image that has a specified histogram.

:

:

( ) :r

r gray level of input image

z gray level of output image

p r pdf of input image

3/20/2012 CS04 804B Image Processing - Module2 48

0

0

( ) :

( ) :

( ) ( ) (1)

( ) ( ) (2)

r

z

r

r

z

z

p r pdf of input image

p z specified pdf of output image

Let s T r p w dw

Define G z p t dt s

= = − − −

= = − − −

Page 49: Image Enhancement Spatial Domain

1 1

(1) (2),

( ) ( )

( ) [ ( )] (3)

From and

G z T r

and zmust satisfy thecondition

z G s G T r− −

=

= = − − −

� T(r) can be obtained from (1) once pr(r) has beenestimated.

� G(z) can be obtained from (2) because pz(z) is given.

3/20/2012 CS04 804B Image Processing - Module2 49

( ) [ ( )] (3)z G s G T r= = − − −

Page 50: Image Enhancement Spatial Domain

� Assume G-1 exists and satisfies (a) and (b). Image with specified histogram can then be obtained as follows:

� Obtain the transformation function T(r) using (1).� Use (2) to obtain the transformation function G(z).� Obtain the inverse transformation function G-1.� Obtain the output image by applying (3) to all the pixels in

the input image.

The resultant image will have gray levels z with specified probabilitiy density function pz(z).

3/20/2012 CS04 804B Image Processing - Module2 50

Page 51: Image Enhancement Spatial Domain

� Discrete formulation:

0

0

( ) ( )

, 0,1,..., 1

k

k k r jj

kj

j

k

s T r p r

nk L

n

=

=

= =

= = −

3/20/2012 CS04 804B Image Processing - Module2 51

0

1

1

( ) ( )

[ ( )], 0,1,..., 1

,

( ), 0,1,..., 1

k

k k z i ki

k k

k k

v G z p z s

z G T r k L

Or

z G s k L

=

= = =

= = −

= = −

Page 52: Image Enhancement Spatial Domain

3/20/2012 52CS04 804B Image Processing - Module2

Page 53: Image Enhancement Spatial Domain

3/20/2012 53CS04 804B Image Processing - Module2

Page 54: Image Enhancement Spatial Domain

Global and Local Enhancement

� Global – pixels are modified based on the gray levelcontent of entire image.

� Local – pixels are modified based on the gray leveldistribution in the neighbourhood of every pixel.

3/20/2012 CS04 804B Image Processing - Module2 54

Page 55: Image Enhancement Spatial Domain

Use of Histogram Statistics� Global mean – measure of average gray level for entire

image.� Local mean – measure of average gray level in the

neighborhood (sub-image).neighborhood (sub-image).

� Global variance – measure of contrast for entire image.� Local variance – measure of contrast in a

neighborhood.

3/20/2012 CS04 804B Image Processing - Module2 55

Page 56: Image Enhancement Spatial Domain

� Spatial Domain Methods� Point Processing

� Linear (Image Negatives and Identity)� Logarithmic (Log and Inverse Log)� Power Law (nth power and nth root)� Piece-wise Linear

� Contrast Stretching� Gray-Level Slicing� Bit-Plane Slicing

� Histogram Processing� Histogram Equalization� Histogram Matching or Histogram Specification

� Enhancement using Arithmetic/ Logic Operations� Image Subtraction� Image Averaging

3/20/2012 CS04 804B Image Processing - Module2 56

Page 57: Image Enhancement Spatial Domain

Enhancement using Arithmetic/Logical Operations

� Arithmetic – operations are performed on a pixel-by-pixelbasis on two or more images.

� Logical – operations are performed on a pixel-by-pixel� Logical – operations are performed on a pixel-by-pixelbasis and pixel values are processed as strings of binarynumbers.� AND and OR – on two or more images

� Used for masking� To highlight an area or differentiate it from rest of the image.

� NOT – on single image.

3/20/2012 CS04 804B Image Processing - Module2 57

Page 58: Image Enhancement Spatial Domain

AND Operation

OR Operation

3/20/2012 58CS04 804B Image Processing - Module2

Page 59: Image Enhancement Spatial Domain

Image Subtraction� The difference between two images f(x,y) and h(x,y) is

obtained by computing the difference between all pairs ofcorresponding pixels from f and h.

� g(x,y) = f(x,y) – h(x,y)

� Used to enhance differences between images.� Used in medical imaging.

3/20/2012 CS04 804B Image Processing - Module2 59

Page 60: Image Enhancement Spatial Domain

Image Averaging� Let g(x,y) be a noisy image formed by the addition of

noise η(x,y) to an image f(x,y). ie;� g(x,y) = f(x,y) + η(x,y)� Assume noise has zero average value.� Assume noise has zero average value.� The noise content in the image can be reduced by adding a

set of noisy images and taking the average

3/20/2012 CS04 804B Image Processing - Module2 60

1

1( , ) ( , )

K

ii

g x y g x yK =

= ∑

Expected value of , { ( , )} ( , )g E g x y f x y=

Page 61: Image Enhancement Spatial Domain

� Mask Processing /Filtering� Linear Spatial Filtering� Non-Linear Spatial Filtering� Smoothing Spatial Filters

� Smoothing Linear Filters� Box-Filter� Weighted Average Filter

� Order-Statistics Filters (Non-Linear Spatial Filters)� Median Filter� Median Filter� Max-filter� Min-filter

� Sharpening Spatial Filters� Second-Order Derivatives

� Laplacian� Unsharp Masking� High Boost Filtering and its Application

� First-Order Derivatives (Gradient)

3/20/2012 CS04 804B Image Processing - Module2 61

Page 62: Image Enhancement Spatial Domain

Spatial Filtering� Uses image pixels in the neighborhood (sub-image).� Sub-image is called mask.� Values in a sub-image are called coefficients.� Values in a sub-image are called coefficients.

� Filtering consists of moving the mask from point to pointin an image. At each point (x,y) response of the filter iscomputed using a predefined relationship.

3/20/2012 CS04 804B Image Processing - Module2 62

Page 63: Image Enhancement Spatial Domain

Linear Spatial Filtering� This involves finding sum of products of filter coefficients

and corresponding pixels in the sub-image.

3/20/2012 CS04 804B Image Processing - Module2 63

Page 64: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 64

Page 65: Image Enhancement Spatial Domain

� Linear filtering of an image f of size MxN with a filter ofsize mxn, is given by

( , ) ( , ) ( , )a b

s a t b

g x y w s t f x s y t=− =−

= + +∑ ∑

3/20/2012 CS04 804B Image Processing - Module2 65

1 1, ,

2 20,1,..., 1 0,1,..., 1.

m nwhere a b

for x M and y N

− −= =

= − = −

Page 66: Image Enhancement Spatial Domain

� For a 3x3 mask,

1 1

1 1

3

3 1 3 11, 1

2 2

( , ) ( , ) ( , )s t

m n

a b

g x y w s t f x s y t=− =−

= =

− −∴ = = = =

= + +∑∑

3/20/2012 CS04 804B Image Processing - Module2 66

1 1

( 1, 1) ( 1, 1) ( 1,0) ( 1, ) ...

(0,0) ( , ) ...

(1,0) ( 1, ) (1,1) ( 1, 1)

s t

w f x y w f x y

w f x y

w f x y w f x y

=− =−

= − − − − + − − +

+ +

+ + + + +

∑∑

Page 67: Image Enhancement Spatial Domain

� Simplified as

For 3x3 mask,

1 1 2 2

1

... mn mn

mn

i ii

R w z w z w z

w z=

= + + +

=∑� For 3x3 mask,

3/20/2012 CS04 804B Image Processing - Module2 67

1

1 1 2 2 9 9...

mn

i ii

R w z

w z w z w z=

=

= + + +

Page 68: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 68

Page 69: Image Enhancement Spatial Domain

� Spatial filtering - Special processing for border pixels� Filter using full mask� Zero padding � Replication of rows or columns.Replication of rows or columns.

3/20/2012 CS04 804B Image Processing - Module2 69

Page 70: Image Enhancement Spatial Domain

Non-Linear Spatial Filtering

� Filtering operation is based conditionally on the values ofpixels in the neighborhood.

� eg; computing median� eg; computing median

3/20/2012 CS04 804B Image Processing - Module2 70

Page 71: Image Enhancement Spatial Domain

� Mask Processing /Filtering� Linear Spatial Filtering� Non-Linear Spatial Filtering� Smoothing Spatial Filters

� Smoothing Linear Filters� Box-Filter� Weighted Average Filter

� Order-Statistics Filters (Non-Linear Spatial Filters)� Median Filter� Median Filter� Max-filter� Min-filter

� Sharpening Spatial Filters� Second-Order Derivatives

� Laplacian� Unsharp Masking� High Boost Filtering and its Application

� First-Order Derivatives (Gradient)

3/20/2012 CS04 804B Image Processing - Module2 71

Page 72: Image Enhancement Spatial Domain

Smoothing Spatial Filters� Smoothing Linear Spatial Filters

� Used for blurring and noise reduction.� Called averaging filters or lowpass filters – Output is the� Called averaging filters or lowpass filters – Output is the

average of pixels contained in the neighborhood of filter mask.

� Replaces every pixel in an image by the average of gray levelsin the neighborhood defined by filter mask.

� Side-effect – blurring of edges and smoothing of falsecontours.

3/20/2012 CS04 804B Image Processing - Module2 72

Page 73: Image Enhancement Spatial Domain

� Box Filter� Spatial averaging filter in which all coefficients are equal.� Standard average of pixels under the mask.

1

1 mn

ii

R zmn =

= ∑

� Weighted Average Filter� Pixels are multiplied by different filter coefficients, giving

more weight to some pixels.

3/20/2012 CS04 804B Image Processing - Module2 73

1imn =

Page 74: Image Enhancement Spatial Domain

� Filtering using Weighted Average Filter is given by

( , ) ( , )( , )

( , )

a b

s a t ba b

w s t f x s y tg x y

w s t

=− =−

+ +=∑ ∑

∑ ∑

3/20/2012 CS04 804B Image Processing - Module2 74

( , )

1 1, , .

2 20,1,..., 1 0,1,..., 1.

s a t b

w s t

m nwhere a b mand nareodd

x M and y N

=− =−

− −= =

= − = −

∑ ∑

Page 75: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 75

Page 76: Image Enhancement Spatial Domain

� Mask Processing /Filtering� Linear Spatial Filtering� Non-Linear Spatial Filtering� Smoothing Spatial Filters

� Smoothing Linear Filters� Box-Filter� Weighted Average Filter

� Order-Statistics Filters (Non-Linear Spatial Filters)� Median Filter� Median Filter� Max-filter� Min-filter

� Sharpening Spatial Filters� Second-Order Derivatives

� Laplacian� Unsharp Masking� High Boost Filtering and its Application

� First-Order Derivatives (Gradient)

3/20/2012 CS04 804B Image Processing - Module2 76

Page 77: Image Enhancement Spatial Domain

� Order-Statistics Filters� Response is based on ordering the pixels and then

repalcing the central pixel value with the value determinedby the ranking result.

Median Filter� Median Filter� Sorts pixel values and computes median .� Replaces value of the pixel with median of gray levels in the

neighborhood.� Excellent noise reduction; less blurring.� Effective in the presence of salt and pepper noise.

3/20/2012 CS04 804B Image Processing - Module2 77

Page 78: Image Enhancement Spatial Domain

� Max Filter� R = max{zk| k=1,2,…mn}.� Used to find the brightest points in an image.

Min Filter� Min Filter� R = min{zk| k=1,2,…mn}.� Used to find the darkest points in an image.

3/20/2012 CS04 804B Image Processing - Module2 78

Page 79: Image Enhancement Spatial Domain

� Mask Processing /Filtering� Linear Spatial Filtering� Non-Linear Spatial Filtering� Smoothing Spatial Filters

� Smoothing Linear Filters� Box-Filter� Weighted Average Filter

� Order-Statistics Filters (Non-Linear Spatial Filters)� Median Filter� Median Filter� Max-filter� Min-filter

� Sharpening Spatial Filters� Second-Order Derivatives

� Laplacian� Unsharp Masking� High Boost Filtering and its Application

� First-Order Derivatives (Gradient)

3/20/2012 CS04 804B Image Processing - Module2 79

Page 80: Image Enhancement Spatial Domain

Sharpening Spatial Filters� Used to highlight the fine detail in an image.� To enhance the detail that has been blurred.� To enhance edges, noise etc.� Sharpening is done through spatial differentiation.� Sharpening is done through spatial differentiation.

� Based on first derivatives

� Based on second derivatives

3/20/2012 CS04 804B Image Processing - Module2 80

( 1) ( )f

f x f xx∂

= + −∂

2

2 ( 1) ( 1) 2 ( )f

f x f x f xx∂

= + + − −∂

Page 81: Image Enhancement Spatial Domain

� First order derivatives� Must be zero in flat segments.� Must be non-zero at the onset of a gray-level step or ramp.� Must be non-zero along ramps.

� Second order derivatives� Second order derivatives� Must be zero in flat areas.� Must be non-zero at the onset and end of a gray-level step or

ramp.� Must be zero along ramps of constant slope.

3/20/2012 CS04 804B Image Processing - Module2 81

Page 82: Image Enhancement Spatial Domain

� Based on first derivatives� Produces thicker edges� Stronger response to gray-level step.

� Based on second derivativesStronger response to finer detail� Stronger response to finer detail

� Produces double response at step changes.

So second-order derivatives are more suited than first-orderderivatives for enhancing fine details.

3/20/2012 CS04 804B Image Processing - Module2 82

Page 83: Image Enhancement Spatial Domain

3/20/2012 CS04 804B Image Processing - Module2 83

Page 84: Image Enhancement Spatial Domain

� Use of Second Derivatives � Laplacian - Laplacian for f(x,y)

2 22

2 2

2

( 1, ) ( 1, ) 2 ( , )

f ff

x y

ff x y f x y f x y

∂ ∂∇ = +

∂ ∂

∂= + + − −

3/20/2012 CS04 804B Image Processing - Module2 84

2

2

2

2

( 1, ) ( 1, ) 2 ( , )

( , 1) ( , 1) 2 ( , )

( 1, ) ( 1, )

( , 1) ( , 1) 4 ( , )

f x y f x y f x yxf

f x y f x y f x yy

f f x y f x y

f x y f x y f x y

= + + − −∂∂

= + + − −∂

∴∇ = + + − +

+ + − −

Page 85: Image Enhancement Spatial Domain

� Highlights gray-level discontinuities

2( , ) ( , )

( , )

if thecentrecoefficient of thef x y f x y

Laplacianmask is negativeg x y

if thecentrecoefficient of the

−∇

=

3/20/2012 CS04 804B Image Processing - Module2 85

2

( , )

( , ) ( , )

g x yif thecentrecoefficient of the

f x y f x yLaplacianmask is positive

= +∇

Page 86: Image Enhancement Spatial Domain

� Unsharp Masking� Subtracts blurred version of the image from the original

image.

( , ) ( , ) ( , )sf x y f x y f x y= −

� Used in dark-room photography.

3/20/2012 CS04 804B Image Processing - Module2 86

Page 87: Image Enhancement Spatial Domain

� High Boost Filtering

( , )

( , ) ( , ) ( , )

( 1) ( , ) ( , ) ( , )

( 1) ( , ) ( , )s

hb

f x y

s

f x y Af x y f x y

A f x y f x y f x y

A f x y f x y

= −

= − + −

= − +

1442443

3/20/2012 CS04 804B Image Processing - Module2 87

( 1) ( , ) ( , )sA f x y f x y= − +

2

2

( , ) ( , )

( , ) ( , )hb

if thecentrecoefficient of theAf x y f x y

Laplacianmask is negativef

if thecentrecoefficient of theAf x y f x y

Laplacianmask is positive

−∇

= +∇

Page 88: Image Enhancement Spatial Domain

� When A = 1, high-boost filtering becomes standardLaplacian sharpening.

� Application:� To make images lighter.

3/20/2012 CS04 804B Image Processing - Module2 88

Page 89: Image Enhancement Spatial Domain

� Use of First Derivatives� Uses magnitude of the gradient.

,

fx

Gradient ffy

∂ ∂ ∇ =∂ ∂

� First order derivatives of a digital image are based onvarious approximations of the 2D gradient.

122 2

y

f fMagnitudeof f

x y

∂ ∂ ∇ = + ∂ ∂

3/20/2012 89CS04 804B Image Processing - Module2

Page 90: Image Enhancement Spatial Domain

� The mathematical implementation of first orderderivatives can be done by masks known as� Roberts cross-gradient operator� Prewitt operator� Sobel operator

• Let the 3 3 area represent the gray levels in a neighborhood of an image, • Let the 3 3 area represent the gray levels in a neighborhood of an image, as shown below

3/20/2012 90CS04 804B Image Processing - Module2

Page 91: Image Enhancement Spatial Domain

Roberts cross-gradient operator

Equations ( )( )

9 5

8 6

x

y

G z z

G z z

= −

= −

Masks

3/20/2012 91CS04 804B Image Processing - Module2

Page 92: Image Enhancement Spatial Domain

Prewitt operator

Equations( ) ( )( ) ( )

7 8 9 1 2 3

3 6 9 1 4 7

x

y

G z z z z z z

G z z z z z z

= + + − + +

= + + − + +

Masks

3/20/2012 92CS04 804B Image Processing - Module2

Page 93: Image Enhancement Spatial Domain

Sobel operator

Equations( ) ( )( ) ( )

7 8 9 1 2 3

3 6 9 1 4 7

2 2

2 2x

y

G z z z z z z

G z z z z z z

= + + − + +

= + + − + +

Masks

3/20/2012 93CS04 804B Image Processing - Module2

Page 94: Image Enhancement Spatial Domain

Thank YouThank You

3/20/2012 CS04 804B Image Processing - Module2 94