93
Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Embed Size (px)

Citation preview

Page 1: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Digital Image Processing

Chapter 3: Intensity Transformations and Spatial Filtering

Page 2: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Background

Spatial domain process

where is the input image, is the processed image, and T is an operator on f, defined over some neighborhood of

)],([),( yxfTyxg ),( yxf ),( yxg

),( yx

Page 3: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Neighborhood about a point

Page 4: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Gray-level transformation function

where r is the gray level of and s is the gray level of at any point

)(rTs ),( yxf

),( yxg),( yx

Page 5: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Contrast enhancement For example, a thresholding function

Page 6: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Masks (filters, kernels, templates, windows) A small 2-D array in which the values of

the mask coefficients determine the nature of the process

Page 7: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Some Basic Gray Level Transformations

Page 8: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Image negatives

Enhance white or gray details

rLs 1

Page 9: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Log transformations

Compress the dynamic range of images with large variations in pixel values

)1log( rcs

Page 10: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

From the range 0- to the range 0 to 6.2

6105.1

Page 11: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Power-law transformations or

maps a narrow range of dark input values into a wider range of output values, while maps a narrow range of bright input values into a wider range of output values

: gamma, gamma correction

crs )( rcs

1

1

Page 12: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 13: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Monitor, 5.2

Page 14: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 15: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 16: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Piecewise-linear transformation functions The form of piecewise functions can be

arbitrarily complex

Page 17: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Contrast stretching

Page 18: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Gray-level slicing

Page 19: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 20: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Bit-plane slicing

Page 21: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 22: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 23: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 24: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 25: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Histogram Processing

Histogram

where is the kth gray level and is the number of pixels in the image having gray level

Normalized histogram

kk nrh )(

kr kn

kr

nnrp kk /)(

Page 26: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 27: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Histogram equalization10 ),( rrTs

10 ),(1 ssTr

Page 28: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 29: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Probability density functions (PDF)

ds

drrpsp rs )()(

r

r dwwpLrTs0

)()1()(

)()1()()1()(

0rpLdwwp

dr

dL

dr

rdT

dr

dsr

r

r

1

1)(

L

sps

Page 30: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

1,...,2,1,0 ,)1()()1()(00

Lkn

nLrpLrTs

k

j

jk

jjrkk

Page 31: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 32: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 33: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 34: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 35: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 36: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 37: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Histogram matching (specification)

r

r dwwpLrTs0

)()1()(

z

z sdttpLzG0

)()1()(

)]([)( 11 rTGsGz

)(zpz is the desired PDF

Page 38: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

1,...,2,1,0 ,)1()()1()(00

Lkn

nLrpLrTs

k

j

jk

jjrkk

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

LkszpLzGv k

k

iizkk

1,...,2,1,0 )],([1 LkrTGz kk

Page 39: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 40: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Histogram matching Obtain the histogram of the given

image, T(r) Precompute a mapped level for each

level Obtain the transformation function G

from the given Precompute for each value of Map to its corresponding level ;

then map level into the final level

)(zpz

kskr

kz kskr ks

ks kz

Page 41: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 42: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 43: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 44: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 45: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 46: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 47: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 48: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Local enhancement Histogram using a local neighborhood,

for example 7*7 neighborhood

Page 49: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Histogram using a local 3*3 neighborhood

Page 50: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Use of histogram statistics for image enhancement denotes a discrete random

variable denotes the normalized histogram

component corresponding to the ith value of

Mean

)( irp

r

r

1

0

)(L

iii rprm

Page 51: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

The nth moment

The second moment

1

0

)()()(L

ii

nin rpmrr

1

0

22 )()()(

L

iii rpmrr

Page 52: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Global enhancement: The global mean and variance are measured over an entire image

Local enhancement: The local mean and variance are used as the basis for making changes

Page 53: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

is the gray level at coordinates (s,t) in the neighborhood

is the neighborhood normalized histogram component

mean:

local variance

tsr ,

)( ,tsrp

xy

xySts

tstsS rprm),(

,, )(

xy

xyxySts

tsStsS rpmr),(

,2

,2 )(][

Page 54: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

are specified parameters is the global mean is the global standard deviation Mapping

210 ,,, kkkEGMGD

otherwise),(

and

if),(

),(21

0

yxf

DkDk

MkmyxfE

yxgGSG

GS

xy

xy

Page 55: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 56: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 57: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 58: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Fundamentals of Spatial Filtering

The Mechanics of Spatial Filtering

)1,1()1,1(

),1()0,1(

),()0,0(

),1()0,1(

)1,1()1,1(

yxfw

yxfw

yxfw

yxfw

yxfwR

Page 59: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Image size: Mask size:

and and

NM nm

a

as

b

bt

tysxftswyxg ),(),(),(

2/)1( ma 2/)1( nb1,...,2,1,0 Mx 1,...,2,1,0 Ny

Page 60: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 61: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 62: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Spatial Correlation and Convolution

Page 63: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 64: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

9

1

992211

...

iii zw

zwzwzwR

Vector Representation of Linear Filtering

Page 65: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Smoothing Spatial Filters

Smoothing Linear Filters Noise reduction Smoothing of false contours Reduction of irrelevant detail

Page 66: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

9

19

1

iizR

Page 67: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

a

as

b

bt

a

as

b

bt

tsw

tysxftswyxg

),(

),(),(),(

Page 68: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 69: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 70: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Order-statistic filters median filter: Replace the value of a

pixel by the median of the gray levels in the neighborhood of that pixel

Noise-reduction

Page 71: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 72: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Sharpening Spatial Filters

Foundation The first-order derivative

The second-order derivative

)()1( xfxfx

f

)(2)1()1(2

2

xfxfxfx

f

Page 73: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 74: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 75: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Use of second derivatives for enhancement-The Laplacian Development of the method

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

2

yxfyxfyxfx

f

2

2

2

22

y

f

x

ff

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

2

yxfyxfyxfy

f

Page 76: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

),(4)]1,(

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

yxfyxf

yxfyxfyxff

positive is

mask Laplacian theof

tcoefficiencenter theif

),(),(

negative is

mask Laplacian theof

t coefficiencenter theif

),(),(

),(

2

2

yxfyxf

yxfyxf

yxg

Page 77: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 78: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 79: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Simplifications

)]1,(

)1,(),1(),1([),(5

),(4)]1,(

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

yxf

yxfyxfyxfyxf

yxfyxf

yxfyxfyxfyxfyxg

Page 80: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 81: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Unsharp masking and highboost filtering Unsharp masking

Substract a blurred version of an image from the image itself

: The image, : The blurred image

),(),(),( yxfyxfyxgmask

),( yxf ),( yxf

),(*),(),( yxgkyxfyxg mask 1, k

Page 82: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

High-boost filtering

),(*),(),( yxgkyxfyxg mask 1, k

Page 83: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 84: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 85: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Using first-order derivatives for (nonlinear) image sharpening—The gradient

y

fx

f

G

G

y

xf

Page 86: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

The magnitude is rotation invariant (isotropic)

2

122

21

22

)(mag

y

f

x

f

GGf yxf

yx GGf

Page 87: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Computing using cross differences, Roberts cross-gradient operators

)( 59 zzGx )( 68 zzGy and

21

268

259 )()( zzzzf

6859 zzzzf

Page 88: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Sobel operators A weight value of 2 is to achieve some

smoothing by giving more importance to the center point

)2()2(

)2()2(

741963

321987

zzzzzz

zzzzzzf

Page 89: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 90: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 91: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering

Combining Spatial Enhancement Methods

An example Laplacian to highlight fine detail Gradient to enhance prominent edges Smoothed version of the gradient

image used to mask the Laplacian image

Increase the dynamic range of the gray levels by using a gray-level transformation

Page 92: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering
Page 93: Digital Image Processing Chapter 3: Intensity Transformations and Spatial Filtering