60
Local Enhancement Histogram processing methods are global processing, in the sense that pixels are modified by a transformation function based on the gray-level content of an entire image. Sometimes, we may need to enhance details over small areas in an image, which is called a local enhancement.

Image Enhancement in the Spatial Domain2

Embed Size (px)

Citation preview

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 1/60

Local Enhancement

• Histogram processing methods are globalprocessing, in the sense that pixels aremodified by a transformation function

based on the gray-level content of anentire image.

• Sometimes, we may need to enhance

details over small areas in an image,which is called a local enhancement.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 2/60

Local Enhancement

• define a square or rectangular neighborhood and move the center ofthis area from pixel to pixel.

• at each location, the histogram of the points in the neighborhood iscomputed and either histogram equalization or histogram specificationtransformation function is obtained.

• another approach used to reduce computation is to utilizenonoverlapping regions, but it usually produces an undesirablecheckerboard effect.

a) Original image(slightly blurred toreduce noise)

b) global histogramequalization (enhance

noise & slightlyincrease contrast butthe construction isnot changed)

c) local histogramequalization using7x7 neighborhood

(reveals the smallsquares inside largerones of the originalimage.

(a)  (b)  (c) 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 3/60

Explain the result in c)

• Basically, the original image consists of manysmall squares inside the larger dark ones.

• However, the small squares were too close ingray level to the larger ones, and their sizes weretoo small to influence global histogramequalization significantly.

• So, when we use the local enhancement

technique, it reveals the small areas.• Note also the finer noise texture is resulted by the

local processing using relatively smallneighborhoods.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 4/60

Enhancement usingArithmetic/Logic Operations

• Arithmetic/Logic operations perform onpixel by pixel basis between two or moreimages

• except NOT operation which perform onlyon a single image

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 5/60

Logic Operations

• Logic operation performs on gray-levelimages, the pixel values are processed asbinary numbers

• light represents a binary 1, and darkrepresents a binary 0

• NOT operation = negative transformation

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 6/60

Example of AND Operation

original image  AND imagemask 

result of ANDoperation 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 7/60

Example of OR Operation

original image OR imagemask 

result of OR operation 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 8/60

Image Subtraction

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

• enhancement of the differences betweenimages

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 9/60

Image Subtraction

• a). original fractal image• b). result of setting the four lower-

order bit planes to zero – refer to the bit-plane slicing

 – the higher planes contributesignificant detail – the lower planes contribute more to

fine detail – image b). is nearly identical visually

to image a), with a very slightlydrop in overall contrast due to lessvariability of the gray-level values in

the image.• c). difference between a). and b).

(nearly black)• d). histogram equalization of c).

(perform contrast stretchingtransformation)

a b

c d

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 10/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 11/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 12/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 13/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 14/60

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.

• our focus will be on masks of odd sizes,e.g. 3x3, 5x5,… 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 15/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 16/60

Spatial Filtering Process

• simply move the filter mask from point topoint in an image.

• at each point (x,y), the response of thefilter at that point is calculated using apredefined relationship.

mn

ii

ii

mnmn

 zw

 zw zw zw R ...2211

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 17/60

Smoothing Spatial Filters

• used for blurring and for 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 byblurring with a linear filter and also by anonlinear filter

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 18/60

Smoothing Linear Filters

• output is simply the average of the pixels

contained in the neighborhood of the filtermask.

• called averaging filters or lowpass filters.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 19/60

Smoothing Linear Filters

• replacing the value of every pixel in an image bythe average of the gray levels in theneighborhood will reduce the “sharp” transitionsin 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)

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 20/60

3x3 Smoothing Linear Filters

box filter  weighted average the center is the most important and otherpixels are inversely weighted as a function of

their distance from the center of the mask 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 21/60

Weighted average filter

• the basic strategy behind weighting thecenter point the highest and then reducingthe value of the coefficients as a function

of increasing distance from the origin issimply an attempt to reduce blurring inthe smoothing process.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 22/60

Example

• a). original image 500x500 pixel

• b). - f). results of smoothing withsquare averaging filter masks ofsize 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 therelative size of the objects that willbe blended with the background.

a b

c d

e f

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 23/60

Order-Statistics Filters (NonlinearFilters)

• the response is based on ordering(ranking) the pixels contained in the imagearea encompassed by the filter

• example – median filter : R = median{zk |k = 1,2,…,n x n} 

 – max filter : R = max{zk |k = 1,2,…,n x n} 

 – min filter : R = min{zk |k = 1,2,…,n x n} • note: n x n is the size of the mask

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 24/60

Median Filters

• replaces the value of a pixel by the median ofthe gray levels in the neighborhood of that pixel(the original value of the pixel is included in the

computation of the median)• quite popular because for certain types of

random noise (impulse noise salt and peppernoise) , they provide excellent noise-reduction

capabilities, with considering less blurring thanlinear smoothing filters of similar size.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 25/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 26/60

26

Example : Median Filters

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 27/60

27

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 aparticular method of image acquisition.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 28/60

28

Blurring vs. Sharpening

• as we know that blurring can be done inspatial domain by pixel averaging in a

neighbors• since averaging is analogous to integration

• thus, we can guess that the sharpening must

be accomplished by spatial differentiation.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 29/60

29

Derivative operator

• the strength of the response of a derivativeoperator is proportional to the degree of

discontinuity of the image at the point at which theoperator is applied.

• thus, image differentiation

 – enhances edges and other discontinuities (noise)

 – deemphasizes area with slowly varying gray-levelvalues.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 30/60

30

First-order derivative

• a basic definition of the first-orderderivative of a one-dimensional functionf(x) is the difference

)()1( x f  x f  x

 f 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 31/60

31

Second-order derivative

• similarly, we define the second-orderderivative of a one-dimensional functionf(x) is the difference

)(2)1()1(2

2

 x f  x f  x f  x

 f 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 32/60

Response of First and Secondorder derivatives

Response of first order derivative is:

• zero in flat segments (area of constant grey values)

• Non zero at the onset of a grey level step or ramp

• Non zero along ramps

Response of second order derivative is:

• Zero in flat areas

• Non zero at the onset of a grey level step or ramp

• Zero along ramps of constant slope

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 33/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 34/60

First and Second-order derivativeof f(x,y)

• when we consider an image function oftwo variables, f(x,y), at which time we willdealing with partial derivatives along the

two spatial axes.

 y

 y x f 

 x

 y x f 

 y x

 y x f 

),(),(),(

2

2

2

22 ),(),(

 y

 y x f 

 x

 y x f  f 

(linear operator) 

Laplacian operator Gradient operator 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 35/60

Discrete Form of Laplacian

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

2

 y x f  y x f  y x f  x

 f 

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

2

 y x f  y x f  y x f  y

 f 

from 

 yield,

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

),1(),1([2

 y x f  y x f  y x f 

 y x f  y x f  f 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 36/60

Result Laplacian mask

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 37/60

Laplacian mask implemented anextension of diagonal neighbors

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 38/60

Other implementation of Laplacianmasks

give the same result, but we have to keep in mind thatwhen combining (add / subtract) a Laplacian-filtered

image with another image. 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 39/60

Effect of Laplacian Operator

• as it is a derivative operator, – it highlights gray-level discontinuities in an

image

 – it deemphasizes regions with slowly varyinggray levels

• tends to produce images that have – grayish edge lines and other discontinuities,

all superimposed on a dark, – featureless background.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 40/60

Correct the effect of featurelessbackground

• easily by adding the original and Laplacianimage.

• be careful with the Laplacian filter used

),(),(

),(),(),(

2

2

 y x f  y x f 

 y x f  y x f 

 y xg

if the center coefficientof the Laplacian mask isnegative 

if the center coefficientof the Laplacian mask ispositive 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 41/60

Example

• a). image of the Northpole of the moon

• b). Laplacian-filtered

image with

• c). Laplacian imagescaled for displaypurposes

• d). image enhanced byaddition with original

image

1 1 1

1 -8 1

1 1 1

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 42/60

Mask of Laplacian + addition

• to simplify the computation, we can createa mask which do both operations,Laplacian Filter and Addition of the original

image.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 43/60

Mask of Laplacian + addition

)]1,()1,( 

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

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

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

 y x f  y x f 

 y x f  y x f  y x f 

 y x f  y x f  y x f 

 y x f  y x f  y x f  y xg

0  -1  0 

-1  5  -1 

0  -1  0 

Example

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 44/60

Example

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 45/60

Note

0  -1  0 

-1  5  -1 

0  -1  0 

0  0  0 

0  1  0 0  0  0 

),(),(

),(),(),(

2

2

 y x f  y x f 

 y x f  y x f  y xg

=  + 0  -1  0 

-1  4  -1 0  -1  0 

0  -1  0 

-1  9  -1 

0  -1  0 

0  0  0 0  1  0 

0  0  0 

=  +  0  -1  0 -1  8  -1 

0  -1  0 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 46/60

Unsharp masking

• to subtract a blurred version of an imageproduces sharpening output image.

),(),(),( y x f  y x f  y x f s

sharpened image = original image  – blurred image 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 47/60

High-boost filtering

• generalized form of Unsharp masking

• A 1

),(),(),( y x f  y x Af  y x f hb

),(),()1(

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

 y x f  y x f  A

 y x f  y x f  y x f  A y x f 

s

hb

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 48/60

High-boost filtering

• if we use Laplacian filter to create sharpenimage fs(x,y) with addition of original image

),(),()1(),( y x f  y x f  A y x f  shb

),(),(

),(),(),(

2

2

 y x f  y x f 

 y x f  y x f  y x f s

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 49/60

High-boost filtering

• yields

),(),(

),(),(),(

2

2

 y x f  y x Af 

 y x f  y x Af  y x f hb

if the center coefficientof the Laplacian mask isnegative 

if the center coefficientof the Laplacian mask ispositive 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 50/60

High-boost Masks

• A 1

• if A = 1, it becomes “standard” Laplacian

sharpening

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 51/60

Example

f

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 52/60

Gradient Operator

• first derivatives are implemented usingthe magnitude of the gradient.

 y

 f  x

 f 

G

G

 y

 xf 

21

22

21

22][)f (

 

  

 

    

 y f 

 x f 

GGmag f   y x

the magnitude becomes nonlinear   y x GG f 

commonly approx. 

z z z

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 53/60

Gradient Mask

• simplest approximation, 2x2

 z1   z2   z3  z4   z5   z6   z7    z8   z9 

)( and )( 5658 z zG z zG  y x

21

2

56

2

582

122

])()[(][ z z z zGG f   y x

5658 z z z z f 

z z z

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 54/60

Gradient Mask

• Sobel operators, 3x3

 z1   z2   z3  z4   z5   z6   z7    z8   z9 

)2()2(

)2()2(

741963

321987

 z z z z z zG

 z z z z z zG

 y

 x

 y x GG f 

the weight value 2 is toachieve smoothing bygiving more important

to the center point 

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 55/60

Note

• the summation of coefficients in all masksequals 0, indicating that they would give aresponse of 0 in an area of constant gray

level.

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 56/60

Example

Example of Combining Spatial

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 57/60

Example of Combining SpatialEnhancement Methods

• want to sharpen theoriginal image andbring out more

skeletal detail.• problems: narrow

dynamic range ofgray level and high

noise content makesthe image difficult toenhance

Example of Combining Spatial

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 58/60

Example of Combining SpatialEnhancement Methods

• solve :

1. Laplacian to highlight fine detail

2. gradient to enhance prominentedges

3. gray-level transformation to

increase the dynamic range ofgray levels

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 59/60

8/2/2019 Image Enhancement in the Spatial Domain2

http://slidepdf.com/reader/full/image-enhancement-in-the-spatial-domain2 60/60