edge detection project

Upload: jenish-macwan

Post on 01-Jun-2018

229 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/9/2019 Edge Detection Project

    1/22

    EE5356 LAB AssignmentEdge detection:

     Take a (256×256) or (512×512) 8-bit/pel image and perform the following edgedetection operations

    1! "obel #perator2! $rewitt #perator%! &obel operator'! aplacian of a*ssian

    5! +ann,s .dge etection

    Procedure:1) &ead an image (an, si0e *p to 512512)!

    2) $erform the edge detection *sing the techni*es mentioned abo3e!%) 4ppl, proper thresholding method and obser3e the dierence in the imagebefore and after appl,ing thresholding!') +ompare the nal image obtained *sing defa*lt 74T4 .dge detection

    operator!

    References:

    1) Anil K Jain, !undamentals of "igital #mage Processing$, %% 3&'(353

    ) Rafael *+ on-ale- and Ric.ard E+/oods, "igital image%rocessing$, 0.ird Edition %% '6 ( '3

    0.eor2 for Edge "etection:

    .dge detection is a terminolog, in image processing and comp*ter 3ision9partic*larl, in the areas of feat*re detection and feat*re etraction9 to refer toalgorithms which aim at identif,ing points in a digital image at which the imagebrightness changes sharpl, or more formall, has discontin*ities! The etraction ofedges or conto*rs from a two dimensional arra, of piels (a gra,-scale image) is acritical step in man, image processing techni*es! 4 3ariet, of comp*tations are

    a3ailable which determine the magnit*de of contrast changes and their orientation!

    There are many ways to perform edge detection. However, the majority of different methods may begrouped into two categories:

    • Gradient:  The gradient method detects the edges by looking for the maximum and minimum in

    the first derivative of the image.

    http://en.wikipedia.org/wiki/Image_processinghttp://en.wikipedia.org/wiki/Computer_visionhttp://en.wikipedia.org/wiki/Feature_detection_(computer_vision)http://en.wikipedia.org/wiki/Feature_extractionhttp://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Digital_imagehttp://en.wikipedia.org/wiki/Luminous_intensityhttp://en.wikipedia.org/wiki/Luminous_intensityhttp://en.wikipedia.org/wiki/Computer_visionhttp://en.wikipedia.org/wiki/Feature_detection_(computer_vision)http://en.wikipedia.org/wiki/Feature_extractionhttp://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Digital_imagehttp://en.wikipedia.org/wiki/Luminous_intensityhttp://en.wikipedia.org/wiki/Luminous_intensityhttp://en.wikipedia.org/wiki/Image_processing

  • 8/9/2019 Edge Detection Project

    2/22

    •  Laplacian: The Laplacian method searches for ero crossings in the second derivative of the

    image to find edges. !n edge has the one"dimensional shape of a ramp and calculating thederivative of the image can highlight its location. #uppose we have the following signal, with anedge shown by the jump in intensity below:

    "*ppose we ha3e the following signal9 with an edge shown b, the :*mp in intensit,

    below

    ;f we take the gradient of this signal (which9 in one dimension9 is :*st the rstderi3ati3e with respect to t) we get the following

    +learl,9 the deri3ati3e shows a maim*m located at the center of the edge in theoriginal signal! This method of locating an edge is characteristic of the *rthermore9 when the rst deri3ati3e is at a maim*m9 the second deri3ati3e is0ero! 4s a res*lt9 another alternati3e to nding the location of an edge is to locatethe 0eros in the second deri3ati3e! This method is known as the aplacian and thesecond deri3ati3e of the signal is shown below

  • 8/9/2019 Edge Detection Project

    3/22

    o4el %erator:

     The "obel operator performs a 2- spatial gradient meas*rement on an image and

    so emphasi0es regions of high spatial fre*enc, that correspond to edges! T,picall,

    it is *sed to nd the approimate absol*te gradient magnit*de at each point in an

    inp*t gra,scale image!

    7athematicall,9 the operator *ses two %×% kernels which are con3ol3ed with theoriginal image to calc*late approimations of the deri3ati3es - one for hori0ontalchanges9 and one for 3ertical! ;f we dene 4 as the so*rce image9 and and ,are two images which at each point contain the hori0ontal and 3ertical deri3ati3eapproimations9 the comp*tations are as follows

    where ? here denotes the 2-dimensional con3ol*tion operation!

     The -coordinate is here dened as increasing in the @right@-direction9 and the ,-coordinate is dened as increasing in the @down@-direction! 4t each point in theimage9 the res*lting gradient approimations can be combined to gi3e the gradientmagnit*de9 *sing

    Asing this information9 we can also calc*late the gradientBs direction

    where9 for eample9 C is D for a 3ertical edge which is darker on the left side!

    http://homepages.inf.ed.ac.uk/rbf/HIPR2/freqdom.htmhttp://en.wikipedia.org/wiki/Convolutionhttp://en.wikipedia.org/wiki/Convolutionhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/freqdom.htmhttp://en.wikipedia.org/wiki/Convolutionhttp://en.wikipedia.org/wiki/Convolution

  • 8/9/2019 Edge Detection Project

    4/22

     The res*lt of the "obel operator is a 2-dimensional map of the gradient at eachpoint! ;t can be processed and 3iewed as tho*gh it is itself an image9 with the areasof high gradient (the likel, edges) 3isible as white lines! The following imagesill*strate this9 b, showing the comp*tation of the "obel operator on a simple image!

    ra,scale image of a brick wall E a bikerack

    Formali0ed sobel gradient image of bricksE bike rack

    Formali0ed sobel -gradient image of

    bricks E bike rack

    Formali0ed sobel ,-gradient image of

    bricks E bike rackPreitt %erator:

    7athematicall,9 the operator *ses two %×% kernels which are con3ol3ed with theoriginal image to calc*late approimations of the deri3ati3es - one for hori0ontal

    changes9 and one for 3ertical! ;f we dene as the so*rce image9 and and

     are two images which at each point contain the hori0ontal and 3erticalderi3ati3e approimations9 the latter are comp*ted as

    http://en.wikipedia.org/wiki/Convolutionhttp://en.wikipedia.org/wiki/File:Bikesgraygh.jpghttp://en.wikipedia.org/wiki/File:Bikesgraygv.jpghttp://en.wikipedia.org/wiki/File:Bikesgraysobel.jpghttp://en.wikipedia.org/wiki/File:Bikesgray.jpghttp://en.wikipedia.org/wiki/Convolution

  • 8/9/2019 Edge Detection Project

    5/22

    &aw /G image of >ort Hood9 TI &es*lt of $rewitt J

     Threshold

    Ro4el o%erator:

     The &oberts +ross operator performs a simple9 *ick to comp*te9 2- spatial

    gradient meas*rement on an image! ;t th*s highlights regions of high spatial

    fre*enc, which often correspond to edges! ;n its most common *sage9 the inp*t to

    the operator is a gra,scale image9 as is the o*tp*t! $iel 3al*es at each point in the

    o*tp*t represent the estimated absol*te magnit*de of the spatial gradient of the

    inp*t image at that point!

    ;n comp*ter 3ision9 the &obertsB +ross operator is one of the earliest edge detection algorithms9 which works b, comp*ting the s*m of the s*ares of the dierencesbetween diagonall, ad:acent piels! This can be accomplished b, con3ol3ing theimage with two 22 kernels

    http://homepages.inf.ed.ac.uk/rbf/HIPR2/freqdom.htmhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/freqdom.htmhttp://en.wikipedia.org/wiki/Computer_visionhttp://en.wikipedia.org/wiki/Edge_detectionhttp://en.wikipedia.org/wiki/Convolutionhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/freqdom.htmhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/freqdom.htmhttp://en.wikipedia.org/wiki/Computer_visionhttp://en.wikipedia.org/wiki/Edge_detectionhttp://en.wikipedia.org/wiki/Convolution

  • 8/9/2019 Edge Detection Project

    6/22

    *om%arison of Edge detection Algorit.m

    riginal o4el 

    Preitt Ro4ert

     

    La%lacian of aussian:

     The aplacian is a 2- isotropic meas*re of the 2nd spatial deri3ati3e of an image! The aplacian of an image highlights regions of rapid intensit, change and istherefore often *sed for edge detection! The aplacian is often applied to an imagethat has rst been smoothed with something approimating a a*ssian "moothinglter in order to red*ce its sensiti3it, to noise! The operator normall, takes a singlegra,le3el image as inp*t and prod*ces another gra,le3el image as o*tp*t!

    http://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htmhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htmhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htmhttp://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htm

  • 8/9/2019 Edge Detection Project

    7/22

     The aplacian L(x,y) of an image with piel intensit, 3al*es I(x,y) is gi3en b,

    "ince the inp*t image is represented as a set of discrete piels9 we ha3e to nd adiscrete con3ol*tion kernel that can approimate the second deri3ati3es in thedenition of the aplacian! Three commonl, *sed small kernels are shown!

    eca*se these kernels are approimating a second deri3ati3e meas*rement on theimage9 the, are 3er, sensiti3e to noise! To co*nter this9 the image is often a*ssian"moothed before appl,ing the aplacian lter! This pre-processing step red*ces thehigh fre*enc, noise components prior to the dierentiation step!

    ;n fact9 since the con3ol*tion operation is associati3e9 we can con3ol3e the a*ssiansmoothing lter with the aplacian lter rst of all9 and then con3ol3e this h,bridlter with the image to achie3e the re*ired res*lt! oing things this wa, has twoad3antages

    • "ince both the a*ssian and the aplacian kernels are *s*all, m*ch smaller

    than the image9 this method *s*all, re*ires far fewer arithmetic operations!•  The o (Kaplacian of a*ssianB) kernel can be precalc*lated in ad3ance so

    onl, one con3ol*tion needs to be performed at r*n-time on the image!

     The 2- o f*nction centered on 0ero and with a*ssian standard de3iation hasthe form

    and is shown

  • 8/9/2019 Edge Detection Project

    8/22

     Fote that as the a*ssian is made increasingl, narrow9 the o kernel becomes the

    same as the simple

    La%lacian  La%lacian of aussian

    *ann27s Edge "etection Algorit.m

    +ann,s approach is based on three basic ob:ecti3es

    1! Low error rate! 4ll edges sho*ld be fo*nd9 and there sho*ld be no sp*rio*sresponses! That is9 the edges detected m*st be as close as possible to the tr*eedges!

  • 8/9/2019 Edge Detection Project

    9/22

    2! Edge points should be well localized! The edges located m*st be as close aspossible to the tr*e edges! That is9 the distances between a point marked as anedge b, the detector and the center of the tr*e edge sho*ld be minim*m!

    %! Single edge point response! The detector sho*ld ret*rn onl, one point for eachtr*e edge point! That is9 the n*mber of local maima aro*nd the tr*e edge sho*ld

    be minim*m! This means that the detector sho*ld not identif, m*ltiple edge pielswhere onl, a single edge point eists!

    ased on these criteria9 the cann, edge detector rst smoothes the image toeliminate and noise! ;t then nds the image gradient to highlight regions with highspatial deri3ati3es! The algorithm then tracks along these regions and s*ppressesan, piel that is not at the maim*m (nonmaim*m s*ppression)! The gradientarra, is now f*rther red*ced b, h,steresis! H,steresis is *sed to track along theremaining piels that ha3e not been s*ppressed! H,steresis *ses two thresholds andif the magnit*de is below the rst threshold9 it is set to 0ero (made a nonedge)! ;fthe magnit*de is abo3e the high threshold9 it is made an edge! 4nd if themagnit*de is between the 2 thresholds9 then it is set to 0ero *nless there is a pathfrom this piel to a piel with a gradient abo3e T2!

    te% 1

    ;n order to implement the cann, edge detector algorithm9 a series of steps m*st befollowed! The rst step is to lter o*t an, noise in the original image before tr,ing tolocate and detect an, edges! 4nd beca*se the a*ssian lter can be comp*ted*sing a simple mask9 it is *sed ecl*si3el, in the +ann, algorithm! #nce a s*itablemask has been calc*lated9 the a*ssian smoothing can be performed *singstandard con3ol*tion methods! 4 con3ol*tion mask is *s*all, m*ch smaller than theact*al image! 4s a res*lt9 the mask is slide o3er the image9 manip*lating a s*are

    of piels at a time! 0.e larger t.e idt. of t.e aussian mas8, t.e loer ist.e detector9s sensitiit2 to noise! The locali0ation error in the detected edgesalso increases slightl, as the a*ssian width is increased! The a*ssian mask *sedin m, implementation is shown below!

    te%

    4fter smoothing the image and eliminating the noise9 the net step is to nd theedge strength b, taking the gradient of the image! The "obel operator performs a 2- spatial gradient meas*rement on an image! Then9 the approimate absol*tegradient magnit*de (edge strength) at each point can be fo*nd! The "obel operator*ses a pair of %% con3ol*tion masks9 one estimating the gradient in the -direction

  • 8/9/2019 Edge Detection Project

    10/22

    (col*mns) and the other estimating the gradient in the ,-direction (rows)! The, areshown below

     The magnit*de9 or edge strength9 of the gradient is then approimated *sing theform*la

    LL M LL J L,L

    te% 3

     The direction of the edge is comp*ted *sing the! Howe3er gradient in the and ,directions9 an error will be generated when s*mI is e*al to 0ero! "o in the codethere has to be a restriction set whene3er this takes place! Ghene3er the gradientin the direction is e*al to 0ero9 the edge direction has to be e*al to ND degreesor D degrees9 depending on what the 3al*e of the gradient in the ,-direction is e*alto! ;f O has a 3al*e of 0ero9 the edge direction will e*al D degrees! #therwise theedge direction will e*al ND degrees! The form*la for nding the edge direction is

     :*st

     Theta M in3tan (, / )

    te% &

    #nce the edge direction is known9 the net step is to relate the edge direction to adirection that can be traced in an image! "o if the piels of a 55 image are alignedas follows

    a

  • 8/9/2019 Edge Detection Project

    11/22

     Then9 it can be seen b, looking at piel @a@9 there are onl, fo*r possible directions

    when describing the s*rro*nding piels - degrees (in the hori0ontal direction)9 &5

    degrees (along the positi3e diagonal)9 ; degrees (in the 3ertical direction)9 or

    135 degrees (along the negati3e diagonal)! "o now the edge orientation has to be

    resol3ed into one of these fo*r directions depending on which direction it is closest

    to (e!g! if the orientation angle is fo*nd to be % degrees9 make it 0ero degrees)! Think of this as taking a semicircle and di3iding it into 5 regions!

     Therefore9 an, edge direction falling within the ,ellow range (D to 22!5 E 15P!5 to18D degrees) is set to D degrees! 4n, edge direction falling in the green range (22!5to 6P!5 degrees) is set to '5 degrees! 4n, edge direction falling in the bl*e range(6P!5 to 112!5 degrees) is set to ND degrees! 4nd nall,9 an, edge direction fallingwithin the red range (112!5 to 15P!5 degrees) is set to 1%5 degrees!

    te% 5

    4fter the edge directions are known9 nonmaim*m s*ppression now has to beapplied! Fonmaim*m s*ppression is *sed to trace along the edge in the edgedirection and s*ppress an, piel 3al*e (sets it e*al to D) that is not considered tobe an edge! This will gi3e a thin line in the o*tp*t image!

    te% 6

    >inall,9 h,steresis is *sed as a means of eliminating streaking! "treaking is thebreaking *p of an edge conto*r ca*sed b, the operator o*tp*t Q*ct*ating abo3eand below the threshold! ;f a single threshold9 T1 is applied to an image9 and anedge has an a3erage strength e*al to T19 then d*e to noise9 there will be instanceswhere the edge dips below the threshold! .*all, it will also etend abo3e the

    threshold making an edge look like a dashed line! To a3oid this9 h,steresis *ses 2thresholds9 a high and a low! 4n, piel in the image that has a 3al*e greater than T1is pres*med to be an edge piel9 and is marked as s*ch immediatel,! Then9 an,piels that are connected to this edge piel and that ha3e a 3al*e greater than T2are also selected as edge piels! ;f ,o* think of following an edge9 ,o* need agradient of T2 to start b*t ,o* donBt stop till ,o* hit a gradient below T1!

    *onclusion:

  • 8/9/2019 Edge Detection Project

    12/22

    Performance of Edge "etection Algorit.ms:

    • radient-based algorit.ms s*ch as the $rewitt lter ha3e a ma:or drawbackof being 3er, sensiti3e to noise! The si0e of the kernel lter and coeRcientsare ed and cannot be adapted to a gi3en image! 4n adapti3e edge-detection algorithm is necessar, to pro3ide a rob*st sol*tion that is

    adaptable to the 3ar,ing noise le3els of these images to help disting*ish 3alidimage contents from 3is*al artifacts introd*ced b, noise!

    •  The performance of the +ann, algorithm depends hea3il, on the ad:*stableparameters9 S9 which is the standard de3iation for the a*ssian filter9 and thethreshold 3al*es9 T1 and T2! S also controls the si0e of the a*ssian filter!

     The bigger the 3al*e for S9 the larger the si0e of the a*ssian filter becomes! This implies more bl*rring9 necessar, for nois, images9 as well as detectinglarger edges! 4s epected9 howe3er9 the larger the scale of the a*ssian9 theless acc*rate is the locali0ation of the edge! "maller 3al*es of S impl, asmaller a*ssian lter which limits the amo*nt of bl*rring9 maintaining neredges in the image! The *ser can tailor the algorithm b, ad:*sting theseparameters to adapt to dierent en3ironments!

    • +ann,s edge detection algorithm is comp*tationall, more epensi3ecompared to "obel9 $rewitt and &oberts operator! Howe3er9 the +ann,s edgedetection algorithm performs better than all these operators *nder almost allscenarios!

  • 8/9/2019 Edge Detection Project

    13/22

  • 8/9/2019 Edge Detection Project

    14/22

  • 8/9/2019 Edge Detection Project

    15/22

    $rewitts .dge etection

  • 8/9/2019 Edge Detection Project

    16/22

    &oberts .dge etection

  • 8/9/2019 Edge Detection Project

    17/22

  • 8/9/2019 Edge Detection Project

    18/22

  • 8/9/2019 Edge Detection Project

    19/22

    aplacian .dge etection

  • 8/9/2019 Edge Detection Project

    20/22

    +ann, .dge etection

  • 8/9/2019 Edge Detection Project

    21/22

  • 8/9/2019 Edge Detection Project

    22/22