Unit 2
Unit 2
Noise is often high frequency in nature; if a gradient operator is applied to an image, the
noise level increases simultaneously. Clearly, smoothing and gradient operators have
conflict in gaims. Some pre-processing algorithms solve this problem and permit
smoothing and edge enhancement simultaneously.
(5.23)
Equation(5.23)is equivalent to discrete convolution with the kernel h,which is called a
convolution mask. Rectangular neighbor hoods are often used with an odd number of
pixels in rows and columns, enabling specification of the central pixel of the neighbor-
hood.
The choice of the local transformation, size, and shape of the neighborhood depends
strongly on the size of objects in the processed image. If objects are rather large, an
image can be enhanced by smoothing of small degradations.
2.2 Image smoothing:
Image smoothing uses redundancy in image data to suppress noise, usually by some
form of averaging of brightness values in some neighborhood . Smoothing poses the
problem of blurring sharp edges, and so we shall consider smoothing methods which
are edge preserving here, the average is computed only from points in the
neighborhood which have similar properties to the point being processed.
Local image smoothing can effectively eliminate impulse noise or
degradationsappearingasthinstripes,butdoesnotworkifdegradationsarelarge blobs or
thick stripes. Such problems may be addressed by image restoration techniques.
The second term here describes the noise, which is again ar and om value with zero
mean and standard deviation Thus, if n images of the same scene are available,
smoothing can be accomplished without blurring the image by
The significance of the pixel in the center of the convolution mask h or its 4neighbors is
sometimes increased, as it better approximates the properties of noise with a Gaussian
probability distribution.
There are two commonly used smoothing filters whose coefficients gradually decrease
to have near-zero values at the window edges. This is the best way to minimize spurious
oscillations in the frequency spectrum. These are the Gaussian and the Butter worth
filters. Larger convolution masks for averaging by Gaussian filter are created according
to the Gaussian distribution formula (equation 5.47) and the mask coefficients are
normalized to have a unit sum.
(a) (b)
(c) (d)
Figure 5.9: Noise with Gaussian distribution and averaging filters. (a) Original image. (b)
Superimposed noise (random Gaussian noise characterized
byzeromeanandstandarddeviationequaltoone-halfofthegray-levelstandard deviation of
the original image). (c) 3 × 3 averaging. (d) 7 × 7 averaging.
An example will illustrate the effect of this noise suppression(lower solution images,
256 256, were chosen deliberately to show the discrete nature of the process). Figure
5.9a shows an original image of Prague castle; Figure 5.9b shows the same image with
superimposed additive noise with Gaussian distribution; Figure 5.9c shows the result of
averaging with a 3x 3 convolution mask (equation 5.27)— noise is significantly reduced
and the image is slightly blurred. Averaging with a larger mask (7 x 7) is demonstrated
in Figure 5.9d, where the blurring is much more serious.
Such filters can be very computationally costly, but this is considerably reduced in the
important special case of separable filters. Separability in 2D means that the
convolution kernel can be factorized as a product of two one- dimensional vectors, and
theory provides a clue as to which convolution masks are separable.
Asanexample, consider abinomic filter. Its elements are binomic numbers which are
created as a sum of the corresponding two numbers in
Pascal’striangle.Considersuchafilterofsize5x5—itcanbedecomposedintoaproduct
Of two
1Dvectors,h1,h2.
Supposeaconvolutionkernelisofsize2N+1.Equation(5.23)allows theconvolution to
beRewrittentaking account ofthespecial properties of separability
where (i, j) specify the mask element. Therefore, only values of pixels with invalidgray-
levelsarereplacedwithanaverageoftheirneighborhoods,andonly valid data contribute to
the averages.
Asecondmethodperformsaveragingonlyifthecomputedbrightnesschange ofapixel is in
somepre-defined interval; this permits repairto large-area errors resulting from slowly
changing brightness of the background without affecting
therestoftheimage.Athirdmethodusesedgestrength(i.e.,gradientmagnitude)
asacriterion.Themagnitudeofsomegradientoperatorisfirstcomputedforthe entire image,
and only pixels with a small gradient are used in averaging. This method effectively
rejects averaging at edges and thereforesuppresses blurring, but setting of the threshold
is laborious.
(a) (b)
Figure5.10: Averagingwithlimiteddatavalidity.(a)Originalcorrupted image. (b) Result of
corruption removal.
Averagingaccordingtoinversegradient
Withinaconvolutionmaskofoddsize,theinversegradientδofapoint(i,j) with respect to the
central pixel (m, n) is defined as
Ifg(m,n)=g(i,j),then wedefineδ(i,j)=2,soδisintheinterval(0,2],and is smaller at the edge
than in the interior of a homogeneous region. Weight coefficients in the convolution
mask h are normalized by the inverse gradient, and thewholeterm is multiplied by 0.5
tokeep brightness valuesin theoriginal
range:themaskcoefficientcorrespondingtothecentralpixelisdefinedash(i,j)
= 0.5. The constant 0.5 has the effect of assigning half the weight to the central pixel (m,
n), and the other half to its neighborhood
Averagingusingarotatingmaskissuchanon-linearmethodthatavoidsedge blur-
ring,andtheresultingimageisinfactsharpened.Thebrightnessaverageis
calculatedonlywithinthisregion;abrightnessdispersionσ2isusedastheregion
homogeneity measure. Let n be the number of pixels in a region R and g be the input
image. Dispersion σ2 is calculated as
Figure5.11:Eightpossiblerotated3×3 masks.
Algorithm5.2:Smoothingusingarotatingmask
1. Considereachimagepixel(i,j).
2. Calculatedispersionforallpossiblemaskrotationsaboutpixel(i,j)according to
equation (5.31).
3. Choosethe mask with minimum dispersion.
4. Assign to the pixel f (i, j) in the output image f the average brightness in the
chosen mask.
Algorithm5.2canbeusediterativelyandtheprocessconvergesquitequickly to a stable
state. The size and shape of masks influence the convergence—the smaller the mask,
the smaller are the changes and more iterations are needed.A larger
mas ksuppressesnoisefaster andthesharpeningeffectisstronger.Onthe other hand,
infor mation about details smaller than the mask may be lost. The number of iterations
is als o influenced by the shape of regions in the image and noise properties.
Med ianfiltering
In probability theory, the median divides the higher half of a probability dist ribution
fromthe lower half. For a random variable x, the median M is the value for w hich the
probability of the outcome x < M is 0.5. The median of a finite list of real num bers is
simply found by ordering the list and selecting the middle member. Lists a re often
cons tructed to be odd in length to secure uniqueness.
Medi an filtering is a non-linear smoothing method that reduces the blurring of e dges, in
which the idea is to replace the current point in the image by the
medianofthebrightnessesinitsneighborhood.Themedianintheneighborhood is not
affected by individual noise spikes and so median smoothing eliminates impul se noise
quitewell.Further, as median filtering does not blur edges much, it can be applied
iteratively. Clearly, performing a sort on pixels within a (possibly large) rect angular
win dow at every pixel position may become very expensive. A more efficient a pproach
[Huang et al., 1979; Pitas and Venetsanopoulos, 1990] is to notice that as the window
moves across a row by one column, the only change to its
–con tents is to lose theleftmost column and replace it with a new rightco lumn—
foram edianwindowofmrowsandncolumns,mn2mpixelsare unchanged and do n ot need
re-sorting. The algorithm is as follows:
nm=nm−H[m],m
=m−1,
untilnm≤t.
8. Iftheright-handcolumnofthewindowisnotattheright-handedgeofthe image,
go to (3).
9. Ifthebottomrowofthewindowisnotatthebottomoftheimage,goto (2).
Median filtering is illustrated in Figure 5.12. The main disadvantage of median filtering
in a rectangular neighborhood is its damaging of thin lines and sharpcorners—
thiscanbeavoidedifanothershapeofneighborhoodisused.For
instance,ifhorizontal/verticallinesneedpreserving,aneighborhoodsuchasthat in Figure
5.13 can be used.
Median smoothing is a special instance of more general rank filtering techniques, the
idea of which is to order pixels in some neighborhood into a sequence.Theresultsofpre-
processingaresomestatisticsoverthissequence,of which the median is one possibility.
Another variant is the maximum or the minimum values of the sequence. This defines
generalizations of dilation and erosion operators in images with more brightness
values.
(a) (b)
Figure 5.12: Median filtering. (a) Image corrupted with impulse noise (14% of image
area covered with bright and dark dots). (b) Result of 3x 3 median filtering.
Non-linearmeanfilter
Figure 5.13: Horizontal/vertical line preserving neighbor- hood for median filtering
Thenon-linearmeanfilterisanothergeneralizationofaveragingtechniques; it is defined by
wheref(m,n)istheresultofthefiltering,g(i,j)isthepixelintheinputimage,Oand is a local
neighborhood of the current pixel (m, n). The function u of one variable has an inverse
function u−1; the a(i, j) are weight coefficients.
Iftheweightsa(i,j)areconstant,thefilteriscalled homomorphic.Some homomorphic
filters used in image processing are:
• Arithmeticmean,u(g) = g.
• Harmonicmean, u(g)=1/g .
• Geometricmean,u(g) =logg .
2.3. Edgedetectors:
Edgedetectorsareacollectionofveryimportantlocalimagepre-processing
methodsusedtolocatechangesintheintensityfunction;edgesarepixels where brightness
changes abruptly.
Edgesarethoseplacesinanimagethatcorrespondtoobject boundaries.
Edgesarepixelswhereimagebrightnesschanges abruptly.
Neurological and psychophysical research suggests that locations in the image in which
the function value changes abruptly are important for image
perception.Edgesaretoacertaindegreeinvarianttochangesofilluminationand viewpoint. If
only edge elements with strong magnitude (edges) areconsidered, such information
often suffices for image understanding. The positive effect of
suchaprocessisthatitleadstosignificantreductionofimagedata.Nevertheless such data
reduction does not undermine understanding the content of the image (interpretation)
in many cases. Edge detection provides appropriate generalization of the image data;
for instance, line drawings perform such a generalization.
Weshallconsiderwhichphysicalphenomenaintheimageformationprocess lead to abrupt
changes in image values—see Figure 5.15. Calculus describes
changesofcontinuousfunctionsusingderivatives;animagefunctiondependson two
variables—co-ordinates in the image plane—and so operators describing
edgesareexpressedusingpartialderivatives.Achangeoftheimagefunctioncan
bedescribedbyagradientthatpointsinthedirectionofthelargestgrowthofthe image
function.
Figure 5.15: Origin of edges, i.e., physical phenomena in image formation process which
lead to edges in images.At right, a Canny edge detection.
An edge is a property attached to an individual pixel and is calculated from the image
function behavior in a neighborhood of that pixel. It is a vector variable with two
components, magnitude and direction.The edge magnitude is
themagnitudeofthegradient, and the edgedirection φ is rotatedwith respect to −
the gradient direction ψ by 90◦.The gradient direction gives the direction of
maximumgrowthofthefunction,e.g.,fromblackf(i,j)=0towhitef(i,j)=
255. This is illustrated in Figure 5.16, in which closed lines are lines of equal brightness.
Theorientation0◦points east.
Edges are often used in image analysis for finding region boundaries. Provided that the
region has homogeneous brightness, its boundary is at the pixels where the image
function varies and so in the ideal case without noise consists of pixels with high edge
magnitude. It can be seen that the boundary and its parts (edges) are perpendicular to
the direction of the gradient.
Figure5.17showsexamplesofseveralstandardedgeprofiles.Edgedetectors are usually
tuned for some type of edge profile.
g g g g
x x x x
Figure5.17:Typicaledgeprofiles.
The gradient magnitude | grad g(x, y)|and gradient direction ψ are continuous image
functions calculated as
wherearg(x, y) is the angle (in radians) from the x axis to (x, y). Sometimes
weareinterestedonlyinedgemagnitudeswithoutregardtotheirorientations— a linear
differential operator called the Laplacianmay then be used. The Laplacian has the same
properties in all directions and is therefore invariant to rotation. It is defined as
Image sharpening [Rosenfeld and Kak, 1982] has the objective of making edgessteeper
—thesharpenedimageisintendedtobeobservedbyahuman.The sharpened output image f
is obtained from the input image g as
f(i, j) =g(i, j)−C S(i, j), (5.36)
where C is a positive coefficient which gives the strength of sharpening and S(i, j) is a
measure of the image function sheerness, calculated using a gradient
operator.TheLaplacianisveryoftenusedforthispurpose.Figure5.18givesan example of
image sharpening using a Laplacian.
Image sharpening can be interpreted in the frequency domain as well. We know that the
result of the Fourier transform is a combination of harmonic functions.
Thederivativeof the harmonicfunction sin(nx) is n cos(nx);thus the higher the
frequency, the higher the magnitude of its derivative.
A similar image sharpening technique to that of equation (5.36), called unsharp
masking, is often used in printing industry applications. A signal
proportionaltoanunsharp(e.g.,heavilyblurredbyasmoothingoperator)image
issubtractedfromtheoriginalimage.Adigitalimageisdiscreteinnatureandso equations
(5.33) and (5.34), containing derivatives, must be approximated by
differences.Thefirstdifferencesoftheimagegintheverticaldirection(forfixed i) and in the
horizontal direction (for fixed j) are given by
∆ig(i, j) =g(i, j) −g(i − n, j) ,
∆jg(i, j) =g(i, j) −g(i, j−n) ,
(5.37)
where n is a small integer, usually 1. The value n should be chosen small enough to
provide a good approximation to the derivative, but large enough to neglect
unimportant changes in the image function. Symmetric expressions for the differences,
∆ig(i, j) =g(i +n,j) −g(i − n, j) ,
∆jg(i, j) =g(i, j + n) −g(i, j −n),
arenot usuallyused becausetheyneglect theimpactof thepixel(i, j) itself.
(a) (b)
Figure5.18:Laplacegradientoperator.(a)Laplaceedgeimageusingthe8-connectivity mask.
(b) SharpeningusingtheLaplaceoperatorequation5.36,C=0.7.Comparethe
sharpening effect with the original image in Figure 5.9a.
Gradient operators as a measure of edge sheerness can be divided into three categories:
1. Operators approximating derivatives of the image function using
differences. Some are rotationally invariant (e.g., Laplacian) and thus are
computedfromoneconvolutionmaskonly.Others,whichapproximatefirst derivatives, use
several masks.The orientation is estimated on the basis of the best matching of several
simple patterns.
2. Operatorsbasedonzero-crossingsoftheimagefunctionsecondderivative (e.g.,
Marr-Hildreth or Canny edge detectors).
3. Operatorswhichattempttomatchanimagefunctiontoaparametricmodel of
edges.
Edgedetectionisanextremelyimportantstepfacilitatinghigher-levelimage
analysisandremainsanareaofactiveresearch.Examplesofthevarietyof
approaches found in current literature are fuzzy logic, neural networks, or wavelets. It
may be difficult to select the most appropriate edge detection strategy.
Individual gradient operators that examine small local neighborhoods are in fact
convolutions (cf. equation 5.23), and can be expressed by convolution masks. Operators
which are able to detect edge direction are represented by a collection of masks, each
corresponding to a certain direction.
Robertsoperator
The Roberts operator is one of the oldest [Roberts, 1965], and is very easy tocompute as
it uses only a 2 × 2 neighborhood of the current pixel. Its masks are
- - -
sothemagnitude oftheedgeiscomputed asg(i, j) −g(i + 1, j + 1) + g(i, j
-
+1) −g(i+1 , j) . (5.40)
The primary disadvantage of the Roberts operator is its high sensitivity to noise,
because very few pixels are used to approximate the gradient.
Laplaceoperator
TheLaplaceoperator∇2isaverypopularoperatorapproximatingthesecond
derivativewhichgivestheedgemagnitudeonly.TheLaplacian,equation(5.35), is
×approximatedindigitalimagesbya convolution sum.A3x3 mask h is often used; for 4-
neighborhoods and 8- neighborhoods it is defined as
ALaplacian operator with stressed significanceof the central pixel or its neighborhood is
sometimes used. In this approximation it loses invariance to rotation
Thedirection ofthegradient is givenby themask giving maximal response. This is also the
case for all the following operators approximating the first derivative.
(a) (b)
(c) (d)
Figure 5.19: First-derivative edge detection using Prewitt operators. (a) North
direction(thebrighterthepixelvalue,thestrongertheedge).(b)Eastdirection.(c) Strong
edges from (a).
(d) Strongedgesfrom(b).
Sobel operator
The Sobel operator is often used as a simple detector of horizontality and verticality of
edges, in which case only masks h1and h3are used. If the h1response is y and the
h3response x, we might then derive edge strength (magnitude) as
Anddirectionasarctan(y/x).
Kirsch operator
To illustrate the application of gradient operators on real images, consider again the
image given in Figure 5.9a. The Laplace edge image calculated is
showninFigure5.18a;thevalueoftheoperatorhasbeenhistogramequalizedto enhance its
visibility.
The properties of an operator approximating the first derivative are
demonstratedusingthePrewittoperator—resultsofothersaresimilar.Theoriginal image is
again given in Figure 5.9a; Prewitt approximations to the directional gradients are in
Figures 5.19a,b, in which north and east directions are shown. Significant edges (those
with above-threshold magnitude) in the two directions are given in Figures 5.19c,d.
2.4. Zero-crossingsofthesecondderivative:
Inthe1970s,Marr’stheoryconcludedfromneurophysiologicalexperiments that
object boundaries are the most important cues that link an intensity image with its
interpretation. Edge detection techniques existing at that time (e.g., the Kirsch, Sobel,
and Pratt operators) were based on convolution in very small
neighborhoodsandworkedwellonlyforspecificimages.Themaindisadvantage of these
edge detectors is their dependence on the size of the object and sensitivity to noise.
An edge detection technique based on the zero-crossings of the second derivative
(Marr-Hildrethedge detector)explores the fact that a step edge
correspondstoanabruptchangeintheimagefunction.Thefirstderivativeofthe image
function should have an extremum at the position corresponding to the edge in the
image, and so the second derivative should be zero at the same position; however, it is
much easier and more precise to find a zero-crossing position than an extremum. In
Figure 5.20 this principle is illustrated in 1D for
thesakeofsimplicity.Figure5.20ashowsstepedgeprofilesoftheoriginalimage
functionwithtwodifferentslopes,Figure5.20bdepictsthefirstderivativeofthe
imagefunction,andFigure5.20cillustratesthesecondderivative;noticethatthis crosses the
zero level at the same position as the edge.
Considering a step-like edge in 2D, the 1D profile of Figure 5.20a corresponds to a cross
section through the 2D step. The steepness of the profile will change if the
where x, y are the image co-ordinates and σ is a standard deviation of the associated
probability distribution. Sometimes this is presented with a normalizing factor
ThestandarddeviationσistheonlyparameteroftheGaussianfilter—itis
proportionaltothesizeoftheneighborhoodonwhichthefilteroperates.Pixelsmore
distantfromthecenteroftheoperatorhavesmallerinfluence,andpixelsfartherthan 3σ from
the center have negligible influence.
Ourgoal is to obtain a second derivative of a smoothed 2D function f (x, y).
WehavealreadyseenthattheLaplaceoperatorgivesthesecondderivative,and is non-
directional (isotropic). Consider then the Laplacian of an image f (x, y)
smoothedbyaGaussian(expressedusingaconvolution).Theoperationisoften abbreviated
as LoG, from Laplacian of Gaussian
andsimilarlyfory. Hence
where c normalizes the sum of mask elements to zero. Because of its shape, the
invertedLoGoperatoriscommonlycalledaMexicanhat.Anexampleofa5× 5 discrete
approximation (wherein a 17 × 17 mask is also given) is
Of course, these masks represent truncated and discrete representations of infinite
continuous functions, and care should be taken in avoiding errors in moving to this
representation.
Finding second derivatives in this way is very robust. Gaussian smoothing
effectivelysuppressestheinfluenceofthepixelsthataremorethanadistance3σ from the
current pixel; then the Laplace operator is an efficient and stable measure of changes in
the image.
(a) (b)
(c) (d)
Figure 5.21: Zero-crossings of the second derivative, see Figure 5.9a for the original
image.
(a) DoGimage(σ1=0.10,σ2=0.09),darkpixels correspondtonegativevalues, bright pixels
to positive. (b) Zero-crossings of the DoG image. (c)
DoGzerocrossingedgesafterremovingedgeslackingfirst-derivativesupport.(d) LoG zero-
crossing edges (σ = 0.20) after removing edges lacking first- derivative support—note
different scale of edges due to different Gaussian smoothing parameters.
well. First, it smooths the shape too much; for example, sharp corners are lost. Second, it
tends to create closed loops of edges (nicknamed the ‘plate of spaghetti’effect).
Neurophysiologicalexperimentsprovideevidencethatthehumaneyeretina
intheformoftheganglioncellsperformsoperationsverysimilartothe operations.Ea
chsuchcellrespondstolightstimuliinalocalneighborhoodcalled the receptive field, which
has a center-surround organization of two complementary types, off-center and on-
center. When a light stimulus occurs, activity of on-center cells increases and that of off-
center cells is inhibited. The retinal operation on the image can be described analytically
as the convolution of the image with the 2G operator.
2.5. Scaleinimageprocessing:
• Manyimageprocessingtechniquesworklocally,theoreticallyatthelevelof
individual pixels—edge detection methods are an example. The essential problem in
such computation is scale.
• Edges correspond to the gradient of the image function, which is computed as
a difference between pixels in some neighborhood.
• There is seldom a sound reason for choosing a particular size of
neighborhood, since the ‘right’size depends on the size of the objects under
investigation.
• To know what the objects are assumes that it is clear how to interpret an
image, and this is not in general known at the pre-processing stage.
• The solution to the problem formulated above is a special case of a general
paradigm called the system approach. This methodology is common in cybernetics or
general system theory to study complex phenomena.
• Thephenomenon underinvestigation is expressed at different resolutions of
the de- scription, and a formal model is created at each resolution. Then the
qualitativebehaviorofthemodelisstudiedunderchangingresolutionofthe description.
Such a methodology enables the deduction of meta-knowledge about the phenomenon
that is not seen at the individual description levels.
• Different description levels are easily interpreted as different scales in the
domain of digital images. The idea of scale is fundamental to Marr’s edge
detectiontechnique,wheredifferentscalesareprovidedbydifferentsizesof
Gaussianfiltermasks.Theaimwasnotonlytoeliminatefinescalenoisebut also to separate
events at different scales arising from distinct physical processes.
• Assumethatasignalhasbeensmoothedwithseveralmasksofvariablesizes.
Everysettingofthescaleparametersimpliesadifferentdescription,butitis
notknownwhichoneiscorrect;formanytasks,noonescaleiscategorically correct. If the
ambiguity introduced by the scale is inescapable, the goal of scale-
independentdescriptionistoreducethisambiguityasmuchaspossible.
• Hereweshallconsiderjustthreeexamplesoftheapplicationofmultiplescale
description to image analysis.
1. Thefirstapproachaimstoprocessplanarnoisycurvesatarangeof scales—thesegmentof
curvethatrepresentstheunderlyingstructureof
thesceneneedstobefound.Theproblemisillustratedbyanexampleof two noisy curves.
• One of these may be interpreted as a closed curve, while the other could be
described as two intersecting straight lines.
• Local tangent direction and curvature of the curve are significant only with
some idea of scale after the curve is smoothed by a Gaussian filter with varying
standard deviations.
2. Asecondapproach,calledscale-spacefiltering,triestodescribesignals
qualitatively with respect to scale. The problem was formulated for 1D
signalsf(x),butitcaneasilybegeneralizedfor2Dfunctionsasimages.
Theoriginal1Dsignalf(x)issmoothedbyconvolutionwitha1D
Gaussian
Ifthestandard deviationσisslowlychanged,thefunction
Canny’sderivationisbasedonseveralideas.
1. Theedgedetectorwasexpressedfora1Dsignalandthefirsttwooptimality
criteria.Aclosed-form solution wasfound using thecalculusof variations.
2. Ifthethirdcriterion(multipleresponses)isadded,thebestsolutionmaybe found
by numerical optimization.The resulting filter can be approximated effectively with
error less than 20% by the first derivative of a Gaussian smoothing filter with standard
deviation σ [Canny, 1986]; the reason for
doingthisistheexistenceofaneffectiveimplementation.Thereisastrong similarity here to
the LoG based Marr-Hildreth edge detector.
3. Thedetectoristhengeneralizedtotwodimensions.Astepedgeisgivenby
itsposition,orientation,andpossiblymagnitude(strength).Itcanbeshown that convolving
an image with a symmetric 2D Gaussian and then differentiating in the direction of the
gradient (perpendicular to the edge direction) forms a simple and effective directional
operator (recall that the Marr-Hildrethzerocrossing operator does not give information
about edge direction, as it uses a Laplacian filter).
Suppose G is a 2D Gaussian [equation (5.47)] and assume we wish to convolve the
image with an operator Gnwhich is a first derivative of G in some direction n
We would like n to be perpendicular to the edge: this direction is not known in advance,
but a robust estimate of it based on the smoothed
gradientdirectionisavailable.Iffistheimage,thenormaltotheedge nis estimated as
Theedgelocationisthenatthelocalmaximumoftheimagefconvolved with the operator
Gnin the direction n
Substitutinginequation(5.56)forGnfromequation(5.54),weget
Estimate localedge normal directions n using equation(5.55) for each pixelin the image.
Computethemagnitudeoftheedgeusingequation(5.58).
Thresholdedgesintheimagewithhysteresistoeliminatespuriousresponses.
hysteresis, employing a hard (high) threshold and a soft (lower) threshold— see
Re pe a ts t e p s (1) th ro u g h( 5 ) forasc en d in g val u e sof t h est a nd a rdd e v ia t io n σ .
A lg o r i t h m 6 .5 . Th e l o w an d h ig h th r e s h o l ds are s e t ac co r ding to an estimated signal-to-
A g gnr eogi as tee trhaetf ii no a. linformationaboutedgesatmultiplescaleusingthe‘feature synthesis’
5. Ta hp ep r o ca oc hr . r e c t scale for the operator depends on the objects contained in the
image.Thesolutiontothisunknownistousemultiplescalesandaggregate information from
them. Different scales for the Canny detector are
representedbydifferentstandarddeviationsσoftheGaussians.Theremay be several scales
of operators that give significant responses to edges (i.e., signal-to-noise ratio above the
thresh- old); in this case the operator with the smallest scale is chosen, as it gives the
best localization of the edge.
Canny proposed a feature synthesis approach. All significant edges
fromtheoperatorwiththesmallestscalearemarkedfirst,andtheedgesof a hypothetical
operator with larger σ are synthesized from them (i.e., a prediction is made of how the
large σ should perform on the evidence gleaned from the smaller σ. Then the
synthesized edge response is compared with the actual edge response for larger σ.
Additional edges are marked only if they have a significantly stronger response than
that predicted from synthetic output.
This procedure may be repeated for a sequence of scales, a cumulative edge map being
built by adding those edges that were not identified at smaller scales.
Figure 5.23a shows the edges of Figure 5.9a detected by a Canny operator with σ =1.0.
Figure5.23b shows theedgedetectorresponsefor σ =2.8 (feature synthesis has not been
applied here).
(a) (b)
Figure5.23:Cannyedgedetectionattwodifferentscales.©CengageLearning 2015.
Canny’s detector represents a complicated but major contribution to edge detection. Its
full implementation is unusual, it being common to find
implementationsthatomitfeaturesynthesis—thatis,juststeps1–5ofAlgorithm 5.4.
2.7. Parametricedgemodels:
Parametric models are based on the idea that the discrete image intensity
functioncanbeconsideredasampledandnoisyapproximationofanunderlying continuous
or piecewise continuous image intensity function.
While this function is not known, it can be estimated from the available discrete image
intensity function and image properties can be determined from this continuous
estimate, possibly with subpixel precision.
It is usually impossible to represent image intensities using a single continuous function
since a single function leads to high-order intensity functions in x and y. Instead,
piecewise continuous function estimates called
facetsareusedtorepresent(aneighborhoodof)eachimagepixel.Suchanimage
representation is called a facet model.
The intensity function in a neighborhood can be estimated using models of different
complexity.
The simplest one is the flat facet model that uses piecewise constants and each pixel
neighborhood is represented by a flat function of constant intensity. The sloped model
uses piecewise linear functions forming a sloped plane fitted to local image intensities.
Quadraticandbi-cubic facetmodelsemploymorecomplexfunctions.
Once the facet model parameters are available for each image pixel, edges
canbedetectedasextremaofthefirstdirectionalderivativeand/orzero-crossings
oftheseconddirectionalderivativeofthelocalcontinuousfacetmodelfunctions.
An example will illustrate: consider a bi-cubic facet model g(i, j) = c1+ c2x + c3y + c4x2 +
c5x y + c6y2 + c7x3 + c8x2 y + c9x y2 + c10y3 ,
(5.59)whoseparametersareestimated from a pixel neighborhood (the co-ordinates of the
central pixel are (0,0)). This may be performed by, e.g., a least-squares method with
SVD; alternatively, coefficients cican be computed directly using a set of ten 5x5 kernels.
Once parameters are available at each pixel, edges may be located as extrema of the first
directional derivative, or zero crossings of the second derivative, of the local facet model
functions.
Benefits:
1) Edgedetectorsbasedonparametricmodelsdescribeedgesmore precisely than
convolution-based edge detectors.
2) Theycarrythepotentialforsubpixeledgelocalization. Limitations:
• Theircomputationalrequirementsaremuch higher.
• PromisingextensionscombinefacetmodelswithCanny’sedgedetection criteria and
relaxation labeling.
2.8. Edgesinmulti-spectralimages:
Onepixelinamulti-spectralimageisdescribedbyann-dimensionalvector, and brightness
values in n spectral bands are the vector components. There are several possibilities for
the detection of edges in multi-spectral images.
Trivially, we might detect edges separately in individual image spectral components using
the ordinary local gradient operators. Individual images of edges can be combined to get
the resulting image, with the value corresponding to edge magnitude and direction
being a selection or combination of the individual edge spectral components.
Alternatively, we may create a multi-spectral edge detector which uses
brightnessinformationfromallnspectralbands;thisapproachisalsoapplicable tomulti-
dimensionalimagesformingthree-orhigher-dimensionaldatavolumes. The neighborhood
used has size 2x n pixels, where the 2x 2 neighborhood is similar to that of the Roberts
gradient, equation (5.39). The coefficients weighting the influence of the component
pixels are similar to the correlation coefficients.Let f(i, j) denote the arithmetic mean of
the brightnesses corresponding to the pixels with the same co-ordinates (i, j) in all n
spectral component images, and frbe the brightness of the rth spectral component. The
edge detector result in pixel (i, j) is given as the minimum of the following expression:
(a)(b) (c)
Figure5.24:Frequencyfiltersdisplayedin3D.(a)Low-passfilter.(b)High- pass filter. (c) Band-
pass filter.
2) Ahigh-passfilterisdefinedbysmalltransferfunctionvalueslocatedaround the frequency
co-ordinate system origin, and larger values outside this area— larger transfer
coefficients for higher frequencies (Figure 5.24b).
• Band-passfilters,whichselect frequencies ina certain rangefor
enhancement,areconstructedin asimilarway,andalsofilters with directional response,
etc. (Fig- ure 5.24c).
Themost common imageenhancement problems includenoise suppression, edge
enhancement, and removal of noise which is structured in the frequency spectrum.
Noise represents a high-frequency image component, and it may be suppressed
applying a low-pass filter as shown in Figure 5.25, which demonstrates the principles of
frequency filtering on Fourier image spectra; the
originalimagespectrumismultipliedbythefilterspectrumandalow-frequency image
spectrum results. Unfortunately, all high-frequency phenomena are
suppressed,includinghighfrequenciesthatarenotrelatedtonoise(sharpedges, lines, etc.).
Low-pass filtering results in a blurred image.
(a) (b)
(c)(d)
Figure 5.25: Low-pass frequency-domain filtering—for the original image and its spectrum
see Figure 3.7. (a) Spectrum of a low-pass filtered image, all higher frequencies filtered
out.
(b) Image resulting from the inverse Fourier transform applied to spectrum (a).
(c) Spectrum of a low-pass filtered image, only veryhighfrequenciesfilteredout.
(d) Inverse Fourier transform applied to spectrum (c).
(a) (b)
(c)(d)
Figure 5.26: High-pass frequency domain filtering. (a) Spectrum of a high- pass filtered
image, only very low frequencies filtered out. (b) Image resulting from the inverse
Fourier transform applied to spectrum (a). (c) Spectrum of a high-pass filtered image,
all lower frequencies filtered out. (d) Inverse Fourier transform applied to spectrum (c).
There are several filters which prove useful for filtering in the frequency domain: two
important representatives of them are the Gaussian and Butterworth filters. Choose an
isotropic filter for simplicity,
TheButterworthfilterisspecifiedtohavemaximallyflatfrequencyresponse
overaspectrumband,andisalsocalleda‘maximallyflatmagnitudefilter’.The frequency
response of the 2D low-pass Butterworth filter Blowof degree n is
(c)
Figure 5.28: Periodic noise removal. (a) Noisy image. (b) Image spectrum
usedforimagereconstruction—notethattheareasoffrequenciescorresponding with
periodic vertical lines are filtered out. (c) Filtered image. © Cengage Learning 2015.
AssumethattheFourierspectrumZ(u,v)isfilteredbythefilterH(u,v)and the spectrum S(u, v) is
the result
S=H . Z=H. I+ H . R. (5.66)
Usually a high-pass filter is used for this purpose; assuming a high-pass Butterworth filter,
it has to be damped in order not to suppress low frequencies
entirelyastheybearneededinformationtoo.TheButterworthfiltermodifiedby damping
coefficient 0.5 is shown in Figure 5.30
Having the filtered spectrum S(u, v), we can return to spatial coordinates
usingtheinverseFouriertransform,s(x,y)=−1S(u,v).Recallthatthelogarithm was first
applied to the input image f (x, y) in equation (5.64). Now the image has to be
transformed by the logarithm inverse function; thisinverse function is the exponential.
The result—the image g(x, y) filtered by the homomorphic filter—is given by g(x, y) =
exp s(x, y) .
Anillustration of the effect of homomorphic filtering is in Figure 5.31, an
imageofapersoninadarktunnelwithstrongilluminationattheentrance.Detail
ofthetunnelsurfaceonthetopandrightsidearenotvisiblebecausethesurface
istoodark.Theresult ofhomomorphicfilteringisinFigure5.31b.Moredetails can be seen in
this image.
(a) (b)
Figure 5.31: Illustration of homomorphic filtering. (a) Original image. (b) Homomorphic
filtering.
2.10. Line detection by local pre-processing operators:
Several other local operations exist which do not belong to the taxonomy
giveninSection5.3,astheyareusedfordifferentpurposessuchaslinefinding, line thinning,
and line filling operators. Another group of operators finds ‘interest points’or
‘locations of interest’in the image.
It is interesting to seek features richer than edges which can be reliably detected in the
image and which can outperform simple edge detectors in some classes of applications.
Line detectors and corner detectors are some such. Line
detectorsareusedtodetectlinearobjectssuchasdimensionlinesinengineering drawings or
railways or roads in satellite images. Corner detectors and other interest point-like
detectors are used mainly to register two or more images one to the other (e.g, in stereo
vision, motion analysis, panorama stitching, object recognition from images) or to index
the image or dominant objects in it to an image database.
Line finding operators aim to find very thin curves in the image; it is
assumedthatcurvesdonotbendsharply.Suchcurvesandstraightlinesarecalled
linesforthepurposeofdescribingthistechnique.Ifacrosssectionperpendicular
indirectiontothetangentofalineisexamined,wegetaroofprofile(seeFigure 5.17) when
examining edges. We assume that the width of the lines is approximately one or two
pixels.
Thepresenceofalinemaybedetectedbylocalconvolutionoftheimagewith con-
volutionkernelswhichserveaslinepatterns.Thesimplestcollectionoffour such patterns of
size 3 x 3 is able to detect lines rotated modulo the angle 45o. Three of four such
convolution kernels are
2.11. Imagerestoration:
Pre-processing methods that aim to suppress degradation using knowledge about its
nature are called image restoration. Most image restoration methods are based on
convolution applied globally to the whole image. There is a wide literature on
restoration and only the basic principles and some simple degradations are considered
here.
Image degradation can have many causes: defects of optical lenses,
nonlinearityoftheelectro-opticalsensor,graininessofthefilmmaterial,relative motion
between an object and camera, wrong focus, atmospheric turbulence in remote sensing
or astronomy, scanning of photographs, etc. The objective of image restoration is to
reconstruct the original image from its degraded version.
Image restoration techniques can be classified as deterministic or stochastic.
Deterministic methods are applicable to images with little noise and a known
degradation function. The original image is obtained by applying the function inverse to
the degraded one. Stochastic techniques try to find the best restoration
accordingtoaparticularstatisticalcriterion,e.g.,aleast-squaresmethod.Thereare
threetypicaldegradationswithasimplefunction:relativeconstantspeedmovement of the
object with respect to the camera, wrong lens focus, and atmospheric turbulence.
Inmostpracticalcases,thereisinsufficientknowledgeaboutthedegradation, and it must be
estimated and modeled. This may be done on an a priori or a posteriori basis:
2.11.1. Apriori knowledge about degradation is either known in advance or
canbeobtainedbeforerestoration.Forexample,ifitisknownthatthe image was degraded
by relative motion of an object with respect to the sensor, then the modeling determines
only the speed and direction of the motion. Alternatively, wemay seek to to
estimateparameters ofadevicesuch as a TV camera or digitizer, whose degradation
remains unchanged over a
periodoftimeandcanbemodeledbystudyingaknownsampleimageand its degraded
version.
2.11.2. A posteriori knowledge is that obtained by analyzing the
degradedimage.Atypical example is to find some interest points in the image
(e.g.,corners,straightlines)andguesshowtheylookedbefore
degradation.Another possibility is to use spectral characteristics of the regions in the
image that are relatively homogeneous.
Adegradedimagegcanarisefromtheoriginalimagefbyaprocesswhichcanbe expressed as
where s is some non-linear function and ν describes the noise. This is often simplified by
neglecting the non-linearity and assuming that the function h is invariant with respect
to position in the image, giving
g(i,j) =(f h)(i,j) +ν(i, j) . (5.75)
If the noise is not significant in this equation, then restoration equates to inverse
convolution (also called deconvolution). If noise is not negligible, then the inverse
convolution is solved as an overdetermined system of linear equations. Methods based
on minimization of least square error such asWiener filtering(off-
line)orKalmanfiltering(recursive,on-line;seeSection16.6.1)are examples [Bates and
McDonnell, 1986].
Wronglensfocus
Image smoothing caused by imperfect focus of a thin lens can be described by the function
where J1is the Bessel function of the first order, r2 = u2 + v2, and a is the displacement— the
model is not space invariant.
Atmosphericturbulence
Atmospheric turbulence is degradation that needs to be restored in remote
sensingandastronomy.Itiscausedbytemperaturenon-homogeneityinthe
atmospherethatdeviates passinglightrays.Onemathematicalmodel[Hufnagel and Stanley,
1964]
is
2.11.3. Wienerfiltering
Wiener (least mean square) filtering [Wiener, 1942; Gonzalez and Woods, 1992; Castle-
man, 1996] attempts to take account of noise properties by incorporatingaprioriknow-
ledgeintheimagerestorationformula.Restoration
bytheWienerfiltergivesanestimatefˆoftheoriginaluncorruptedimagefwith minimal
mean square error
! "
(5.82)
wheredenotesthemeanoperator.𝖲Ifnoconstraintsareappliedtothesolution of
equation (5.82), then an optimal estimate fˆ is the conditional mean value of the
ideal image f under the condition g. This approach is complicated from the
computational point of view. Moreover, the conditional probability density
between the optimal image f and the corrupted image g is not usually known.
The optimal estimate is in general a non- linear function of the image g.
ˆ
Minimization of equation (5.82) is easy if the estimate f is a linear combination of
the
values in image g; the estimatefˆ is then close (but not necessarily equal) to the
theoretical optimum. The estimate is equal to the theoreticalopti
DenotetheFouriertransformoftheWienerfilter byHW.Then,theestimate Fˆ of the
Fourier transform F of the original image f can be obtained as
HWisnotderivedhere,butmaybefoundelsewhere[GonzalezandWoods,1992]as
(a) (b)
Figure5.36:RestorationofmotionblurusingWienerfiltering.CourtesyofP.Kohout,
Criminalistic Institute, Prague.