You are on page 1of 74

IMAGEENHANCEMENT

www.jntuworld.com

Textbook
Digital Image Processing
by Gonzales/Woods
Acknowledgements
Dr. Rolf Lakaemper

www.jntuworld.com

UNIT3

www.jntuworld.com

Image ENHANCEMENT
www.jntuworld.com

in the
Image
ENHANCEMENT
SPATIAL
DOMAIN
in the
SPATIAL DOMAIN

www.jntuworld.com

Pointprocessing/intensitytransformations/graylevel
transformations
>ImageNegatives
>LogTransformations
>PowerLawTransformations
>PiecewiseLinearTransformationFunctions

Contraststretching
Thresholding
Graylevelslicing
Bitplaneslicing

Maskprocessing/spatialfiltering

www.jntuworld.com

Spatialdomaintechniques

www.jntuworld.com

Imageenhancement:
1. Improvingtheinterpretabilityorperceptionof
informationinimagesforhumanviewers
2. Providing`better'inputforotherautomatedimage
processingtechniques
Spatialdomainmethods:
operatedirectlyonpixels
Frequencydomainmethods:
operateontheFouriertransformofanimage

www.jntuworld.com

ImageEnhancement(Spatial)

www.jntuworld.com

Thesimplestkindofrangetransformationsare
theseindependentofpositionx,y:
g=T(f)
Thisiscalledpointprocessing.
Important: everypixelforhimself spatial
informationcompletelylost!

www.jntuworld.com

PointProcessing

T transforms the given image f(x,y)


into another image g(x,y)
www.jntuworld.com

f(x,y)

g(x,y)

www.jntuworld.com

Remember ?

Operation on the set of image-pixels

www.jntuworld.com

12 200 20 10

(Operator: Div. by 2)

100 10 5

www.jntuworld.com

Spatial Domain

Operation on the set of neighborhoods


N(x,y) of each pixel
6

(Operator: sum)

www.jntuworld.com

12 200
6

12 200 20 10

226

www.jntuworld.com

Spatial Domain

Operation on a set of images f1,f2,


6

www.jntuworld.com

12 200 20 10
(Operator: sum)

11

13 3

14 220 23 14
5

20 3

www.jntuworld.com

Spatial Domain

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

Operation on the set of image-pixels


Remark: these operations can also be seen as operations on the
neighborhood of a pixel (x,y), by defining the neighborhood as the
pixel itself.
www.jntuworld.com

The easiest case of operators


g(x,y) = T(f(x,y)) depends only on the value
of f at (x,y)
T is called a
gray-level or intensity transformation
function

www.jntuworld.com

Spatial Domain

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

Basic Gray Level Transformations

www.jntuworld.com

Image Negatives
Log Transformations
Power Law Transformations
Piecewise-Linear Transformation
Functions

For the following slides L denotes the max. possible gray value of the
image, i.e. f(x,y) [0,L-1]

www.jntuworld.com

Transformations

www.jntuworld.com

Output gray level

Image Negatives: s=L-r-1

Input gray level

www.jntuworld.com

Transformations

Log Transformations:
s = c * log (1+ r)

www.jntuworld.com

Transformations

www.jntuworld.com

www.jntuworld.com

Transformations

Log Transformations

www.jntuworld.com

InvLog

Log

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

Acathoderaytube(CRT),forexample,
convertsavideosignaltolightinanonlinear
way.ThelightintensityI isproportionaltoa
power() ofthesourcevoltageVS
ForacomputerCRT, isabout2.2
Viewingimagesproperlyonmonitorsrequires
correction

www.jntuworld.com

Whypowerlawsarepopular?

Power Law Transformations or


Gamma Transformations
s= cr

www.jntuworld.com

Transformations

www.jntuworld.com

www.jntuworld.com

varying gamma () obtains family


of possible transformation curves
>1
Compresses dark values
Expands bright values
<1
Expands dark values
Compresses bright values

www.jntuworld.com

Transformations

Used for gamma-correction

www.jntuworld.com

Transformations

www.jntuworld.com

Used for general purpose contrast manipulation

www.jntuworld.com

Transformations

www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

Piecewise Linear Transformations

www.jntuworld.com

Transformations

www.jntuworld.com

Thresholding Function

Output gray
level

www.jntuworld.com

r1=r2 and s1=0 and s2=L-1


g(x,y) =
L if f(x,y) > t,
0 else
t = threshold level

Input gray level

www.jntuworld.com

Piecewise Linear Transformations

Gray Level (Intensity level) Slicing


Purpose: Highlight a specific range of gray values
Two approaches:
www.jntuworld.com

1. Display high value for range of interest, low value


else (discard background)

2. Display high value for range of interest, original


value else (preserve background)

www.jntuworld.com

Piecewise Linear Transformations

Gray Level Slicing

www.jntuworld.com

Piecewise Linear Transformations

www.jntuworld.com

Bit-plane Slicing
www.jntuworld.com

Extracts the information of a


single bit-plane

www.jntuworld.com

Piecewise Linear Transformations

www.jntuworld.com

Piecewise Linear Transformations

www.jntuworld.com

BP 0

BP 5

BP 7

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

Smootheningfilters
www.jntuworld.com

Lowpassfilters
Medianfilters

Sharpeningfilters
Highboostfilters
Derivativefilters

www.jntuworld.com

Spatialfilters

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

Uses
www.jntuworld.com

Blurring
Noisereduction

www.jntuworld.com

Smoothinglinearfilters/averaging
filters/lowpassfilters(linearfilter)

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

www.jntuworld.com

www.jntuworld.com

www.jntuworld.com

Objective:
www.jntuworld.com

Replacethevalveofthepixelbythemedianofthe
intensityvaluesintheneighbourhoodofthatpixel

Principlefunction:
Forcepointswithdistinctintensitylevelstobemore
liketheirneighbours

Uses:
Noisereduction
Lessblurring
Reduceimpulsenoise

www.jntuworld.com

Orderstaticfilter/(nonlinear
filter)/medianfilter

Objective:
Highlightfinedetailsinanimage
www.jntuworld.com

Applications:
Electronicprinting
Medicalimaging
Industrialinspection
Autonomoustargetdetection

www.jntuworld.com

Sharpeningspatialfilters

www.jntuworld.com

Principle:
Subtractanunsharpimagefromtheoriginalimage

Uses:
Printingindustry
Publishingindustry

www.jntuworld.com

Highboostfiltering/
Highfrequencyemphasisfilter/
Unsharpmasking

www.jntuworld.com

www.jntuworld.com

Processsteps:
1.blurtheoriginalimage
2.subtracttheblurredimagefromtheoriginal
(thedifferenceisthemask)
3.addtheweightedmasktotheoriginal

Thederivativesofdigitalfunctionsaredefined
intermsofdifferences.

www.jntuworld.com

Derivativefiltering

www.jntuworld.com

www.jntuworld.com

1. Mustbezeroinareasofconstantintensity
2. Mustbenonzeroattheonsetofanintensity
steporramp
3. Mustbenonzeroalongtheramps

Secondderivative
1. Mustbezeroinareasofconstantintensity
2. Mustbenonzeroattheonsetandendofan
intensitysteporramp
3. Mustbezeroalongtherampsofconstantslope

www.jntuworld.com

Firstderivative:

www.jntuworld.com

Firstderivativesinimageprocessingare
implementedusingmagnitudeofthegradient.
Uses:
Industrialinspection
Enhancedefects
Eliminateslowlychangingbackgroundfeatures

www.jntuworld.com

Usingthefirstorderderivativesfor(non
linear)imagesharpeningTheGradient

www.jntuworld.com

www.jntuworld.com

www.jntuworld.com

www.jntuworld.com

Uses
www.jntuworld.com

Highlightsintensitydiscontinuitiesinanimage
Deemphasizesregionswithslowlyvaryingintensity
levels.

www.jntuworld.com

Usingthesecondderivativesfor(linear)
imagesharpeningTheLaplacian

Different variants of the Laplacian

www.jntuworld.com

Spatial Filtering

www.jntuworld.com

www.jntuworld.com

www.jntuworld.com

Histogramprocessing

www.jntuworld.com

www.jntuworld.com

Histogramprocessing
Histogramequalization
Histogrammatching/specification

www.jntuworld.com

number of pixels

Remember:
The histogram shows the number of
pixels having a certain gray-value

Gray-value (0..1)

www.jntuworld.com

Histograms

The NORMALIZED histogram is the


histogram divided by the total number
of pixels in the source image.
www.jntuworld.com

The sum of all values in the normalized


histogram is 1.
The value given by the normalized
histogram for a certain gray value can
be read as the probability of randomly
picking a pixel having that gray value

www.jntuworld.com

Histograms

www.jntuworld.com

What can the (normalized)


histogram tell about the
image ?

www.jntuworld.com

Histograms

www.jntuworld.com

Histograms

1.The MEAN VALUE (or average gray


www.jntuworld.com

level)

M = g h(g)
g

1*0.3+2*0.1+3*0.2+4*0.1+5*0.2+6*0.1=
2.6

0.3
0.2
0.1
0.0

1 2 3 4 5 6

www.jntuworld.com

The MEAN value is the average gray


value of the image, the overall

brightness appearance.

www.jntuworld.com

Histograms

2. The VARIANCE
www.jntuworld.com

V = g (g-M)2 h(g)
(with M = mean)
or similar:

The STANDARD DEVIATION


D = sqrt(V)

www.jntuworld.com

Histograms

VARIANCE gives a measure about the


distribution of the histogram values
around the mean.
www.jntuworld.com

0.3
0.2
0.1
0.0

0.3
0.2
0.1
0.0
V1

>

V2

www.jntuworld.com

Histograms

www.jntuworld.com

The STANDARD DEVIATION is a value


on the gray level axis, showing the
average distance of all pixels to the
mean
0.3
0.2
0.1
0.0

0.3
0.2
0.1
0.0
D1

>

D2

www.jntuworld.com

Histograms

VARIANCE and STANDARD DEVIATION


of the histogram tell us about the
average contrast of the image !
www.jntuworld.com

The higher the VARIANCE (=the higher


the STANDARD DEVIATION), the
higher the images contrast !

www.jntuworld.com

Histograms

www.jntuworld.com

xaxis valuesofintensitiesrk
yaxis h(rk)orp(rk)

www.jntuworld.com

ImageHistograms

www.jntuworld.com

Histogramequalization

www.jntuworld.com

www.jntuworld.com

Arandomvariable X hasdensity,where isanonnegative

Hence,ifF isthecumulativedistributionfunction ofX,then:

Theprobabilitydensityfunction(PDF)ofacontinuousdistributionis
definedasthederivativeofthecumulativedistributionfunction
[source:wikipedia]

www.jntuworld.com

Inprobabilitytheory,aprobabilitydensityfunction (abbreviatedas
pdf,orjustdensity)ofacontinuousrandomvariable isafunction
thatdescribestherelativelikelihoodforthisrandomvariableto
occuratagivenpointintheobservationspace.Theprobabilityofa
randomvariablefallingwithinagivensetisgivenbytheintegral of
itsdensityovertheset.

Histogram Equalization:

www.jntuworld.com

Preprocessing technique to
enhance contrast in natural
images
Target: find gray level
transformation function T to
transform image f such that the
histogram of T(f) is equalized

www.jntuworld.com

Histograms

Idea:applyamonotonetransformresultinginan
approximatelyuniformhistogram

www.jntuworld.com

HistogramEqualization(Idea)

www.jntuworld.com

www.jntuworld.com

Histogram Equalization

Example:

www.jntuworld.com

We are looking for


this transformation !

www.jntuworld.com

www.jntuworld.com

Discrete:
www.jntuworld.com

g1 is mapped to the (normalized)


number of pixels having
gray-values 0..g1 .

www.jntuworld.com

Histogram Equalization

www.jntuworld.com

HistogramEqualization

www.jntuworld.com

www.jntuworld.com

Histogrammatchingor
Histogramspecification
www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com

www.jntuworld.com

Chapter 3
Image Enhancement in the
Spatial Domain

www.jntuworld.com