edges - micc · • tracing&edges&&...

22
Edges

Upload: others

Post on 23-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Edges  

Page 2: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  Edge  detec*on  schemes  can  be  grouped  in  three  classes:  –  Gradient  operators:  Robert,  Sobel,  Prewi>,  and  Laplacian  (3x3  and  5x5  masks)  –  Surface  fiHng  operators:  Hueckel,  Hartly  and  Haralick    –  Based  on  Gaussian  deriva*ves:  Canny  

•  Typically  two  stages  are  needed  in  edge  detec*on    1.  Detec*on  of  short  linear  edge  segments  (edgels)  using  the  edge  detec*on  operators  2.  Aggrega*on  of  edgels  into  extended  edges    

Edge  detectors  

Page 3: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Gradient  based  methods  

•  Many  edge-­‐detec*on  operators  are  based  upon  the  1st  deriva*ve  of  the  intensity.    

 Where  the  biggest  change  occurs,  the  deriva*ve  has  maximum  magnitude.    Using  this  informa*on  we  can  search  an  image  for  peaks  in  the  intensity  gradient.  The  gradient  of  an  image    f  (x,y)    is:                                                                        

     

     

   

•  The  edge  direc.on  is  given  by:  •  The  edge  strength  is  given  by  the  gradient  magnitude:  

θ  

Page 4: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

         

Δy   Δx  Δy  Δx      (x-­‐1,y+1)    (x,y+1)                (x+1,y+1)  

     (x-­‐1,y)                (x,y)                        (x+1,y)  

 

   (x-­‐1,y-­‐1)              (x,y-­‐1)            (x+1,y-­‐1)        

3x3 Sobel operator Sobel  window  

             

 

Sobel  operator  

•  The  Sobel  operator  calculates  the  gradient  of  the  image  intensity  at  each  point,  giving  the  direc*on  of  the  largest  possible  increase  from  light  to  dark  and  the  rate  of  change  in  that  direc*on.    

•  Mathema*cally,  the  operator  uses  two  3×3  kernels  which  are  convolved  with  the  original  image  to  calculate  approxima*ons  of  the  deriva*ves,    one  for  horizontal  changes,  and  one  for  ver*cal.  The  Sobel  operator  represents  a  rather  inaccurate  approxima*on  of  the  image  gradient:    

–  it  uses  intensity  values  only  in  a  3×3  region  around  each  image  point    –  it  uses  only  integer  values  for  the  coefficients  

•  But  it  is  s*ll  of  sufficient  quality  to  be  of  prac*cal  use  in  many  applica*ons.  

Page 5: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

         

   (a)  2x2  Roberts  operator      (b)  3x3  Prewi>  operator              (c)  4x4  Prewi>  operator  

Other  gradient  operators    

Δy   Δx  

Δx  Δx  Δy   Δy  

Δy  Δx  

(c)

Page 6: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

a)   b)  

d)   c)  

   Canny  edge  detector    

•       The  Canny  algorithm  aims  at  performing  op*mal  edge  detec*on.  It  is  comprised  of  several              cascade  stages:  

Original  image  Norm  of  the  gradient  aaer  noise  reduc*on  

Thresholding  with  hysteresis  

Thinning                      (non-­‐maximum  suppression)  

 

Page 7: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  Noise  reduc*on      First  deriva*ves  are  suscep*ble  to  noise  present  on  raw  unprocessed  image  data.  Canny  edge  

detec*on  performs  convolu*on  of  the  original  image  with  a  Gaussian  filter  to  remove  noise.  The  result  is  a  slightly  blurred  version  of  the  original  image.            Consider  a  single  row  or  column  of  the  image  and  plot  intensity  as  a  func*on  of  posi*on.                      If  pixels  are  disturbed  with  noise  and  the  if  deriva*ve  of  the  signal  is  computed,  edges  are  not  any  more  dis*nguishable.  

Page 8: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Smoothing  the  image  by  using  a  low  pass  Gaussian  filter    h        permits  to  remove  noise.                      Edges  are  clearly  evidenced  in  correspondence  of  peaks  of  

Page 9: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•     According  to  the  deriva*ve  theorem  of  convolu*on  one  opera*on  can  be  saved:  

Page 10: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  Finding  the  intensity  gradient  direc*on    the  Canny  algorithm  uses  four  filters  to  detect  horizontal,  ver*cal  and  diagonal  edges  in  the  blurred  image.  For  each  pixel,  the  direc*on  of  the  filter  which  gives  the  largest  response  magnitude  is  determined.  This  direc*on  together  with  the  filter  response  then  gives  the  complete  es*ma*on  of  the  intensity  gradient  at  each  point  in  the  image.  

 

•  Non-­‐maximum  suppression    a  search  is  then  carried  out  to  determine  if  the  gradient  magnitude  assumes  a  local  maximum  in  the  gradient  direc*on.  This  requires  checking  interpolated  pixels  p  and  r.  Non  maximum  pixels  are  suppressed.  As  a  result  a  set  of  edge  points,  in  the  form  of  a  binary  image,  is  obtained  ("thin  edges”).  

 

Page 11: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  Tracing  edges    

 important  edges  are  along  con*nuous  curves  in  the  image.  Therefore  edges  are  detected  if  the  faint  sec*on  of  the  edge  line  is  followed  and  noisy  pixels  that  do  not  cons*tute  a  line  but  have  produced  large  gradients  are  discarded.  Edges  are  traced  in  the  image  using  thresholding  with  hysteresis.  

   Hysteresis  uses  a  high  threshold  to  start  edge  curves  and  a  low  threshold  to  con*nue  them.  Use  of  high  threshold  marks  out  the  edges  that  are  genuine.  Star*ng  from  these,  using  the  direc*onal  informa*on,  edges  can  be  traced  through  the  image.    

   For  each  edge  point,  the  tangent  to  the  edge  curve  (which  is  normal  to  the  gradient  at  that  point)  is  used  to  predict  the  next  points  (here  either  r  or  s).  

While  tracing  an  edge,  we  apply  the  lower  threshold,  allowing  us  to  trace  faint  sec*ons  of  edges  as  long  as  we  find  a  star*ng  point.  We  obtain  a  binary  image  where  each  pixel  is  marked  as  either  an  edge  pixel  or  a  non-­‐edge  pixel.    

Page 12: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  The  Canny  algorithm  contains  a  number  of  adjustable  parameters,  which  can  affect  the  

computa*on  *me  and  effec*veness  of  the  algorithm  (h>p://matlabserver.cs.rug.nl):  

–  The  size  of  the  Gaussian  filter:    •  smaller  filters  cause  less  blurring,  and  allow  detec*on  of  small,  sharp  lines;    •  larger  filters  cause  more  blurring  and  are  more  useful  for  detec*ng  larger,  

smoother  edges.      

–  Thresholds:    •  Eliminates  noise  edges  and  makes  edges  smoother.  •  Removes  fine  detail.  •  the  use  of  two  thresholds  with  hysteresis  allows  more  flexibility  than  in  a  single-­‐

threshold  approach;    

Page 13: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Canny  with  large  σ     Canny  with  small  σ    original    

•  The  choice  of    σ    depends  on  desired  behavior:  –  large                detects  large  scale  edges  –  small                detects  fine  features  

             Effects  of  σ  (Gaussian  kernel  size)  

Page 14: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

             Effects  of  thresholding    

Coarse  scale  low  threshold

•   A  too  high  threshold  can  miss  important  informa*on;  a  too  low  threshold  will  falsely          iden*fy  irrelevant  informa*on  as  important.  

Fine  scale  high  threshold                                                                                            Coarse  scale  high  threshold  

Page 15: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Lines  

Page 16: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

 What  is  a  line  

•  Lines  can  be  detected  following  different  approaches:    –  searching  for  changes  of  the  intensity  gradient  (double  edges)  at  every  possible  

posi*on/orienta*on  –  using  a  vo*ng  scheme  in  the  line  parameter  space  

•  An  edge  is  not  a  line...  a  line  is  a  double  edge  

Page 17: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  In  correspondence  of  lines  there  is  an  intensity  gradient  on  one  side  of  the  line,  followed  immediately  by  the  opposite  gradient  on  the  opposite  side.  Therefore  lines  exhibit  a  very  high  change  in  intensity  gradient.  According  to  this,  line  detec*on  can  be  based  upon  local  maxima  of  the  1st  deriva*ve  of  the  intensity  that  gives  the  rate  of  change  in  intensity  gradient.    

•  Assume  that  the  image  has  been  pre-­‐smoothed  by  Gaussian  smoothing  and  a  scale-­‐space  representa*on  L(x,y;t)  at  scale  t  is  obtained  and  introduce  t  every  image  point  a  local  coordinate  system  (u,v),  with  the  v-­‐direc*on  parallel  to  the  gradient  direc*on.  It  is  therefore  required  that  the  first-­‐order  direc*onal  deriva*ve  in  the  v-­‐direc*on  Lv  has  its  first  order  direc*onal  deriva*ve  in  the  v-­‐direc*on  equal  to  zero  while  the  second-­‐order  direc*onal  deriva*ve  in  the  v-­‐direc*on  should  be  nega*ve.    

•  Local  maxima  of  the  intensity  gradient  are  hence  obtained  by  detec*ng  zero-­‐crossings  of  the  second-­‐order  direc*onal  deriva*ve  in  the  gradient  direc*on:        

               that  sa*sfies  the  following  sign-­‐condi*on  on  the  third-­‐order  direc*onal  deriva*ve  in  the  same  

direc*on:                      where  Lx,  Ly  ...  Lyyy,  are  local  par*al  deriva*ves.    

Zero-­‐crossing  of  Laplacian  line  detector  

Page 18: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Laplacian  of  Gaussian  Gaussian   Deriva*ve  of  Gaussian  

•  In  prac*ce  the  image  is  convolved  with  the  2D  Laplacian  of  Gaussian:  

that  can  be  approximated  by  compu*ng  the  first  image  deriva*ves  with  first  order  difference  operators  as  with  edges  and  second  order  deriva*ves  as:  

Page 19: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  Lines  are  at  zero  crossings  of  the  Laplacian  of  Gaussian:  

Page 20: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Hough  transform-­‐based  line  detector  

–  A  line  in  the  image  corresponds  to  a  point  in  the  Hough  space  –  To  go  from  image  space  to  Hough  space:  given  a  set  of  points  (x,y),  find  all  (m,b)  such  

that  y  =  mx  +  b  

x  

y  

m  

b  

m0  

b0  

image  space   Hough  space  

•  Hough  transform  vo*ng  scheme  is  the  most  commonly  used  solu*on  to  find  lines  in  images.                In  this  approach,    points  vote  for  a  set  of  parameters  describing  a  line  or  a  curve.  The  more                votes  for  a  par*cular  set  determine  the  line  parameters.  Mul*ple  lines  or  curves  can  be                detected  in  one  shot.  

Page 21: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

•  Typically  a  different  parameteriza*on  is  used:  

d  is  the  perpendicular  distance  from  the  line  to  the  origin  θ  is  the  angle  between    d  and  the x axis  

 

•  Basic  Hough  transform  algorithm  1.  Ini*alize  an  accumulator  H[d, θ]  with  a  suitable  number  of  bins  corresponding  

to  all  possible  line  orienta*ons  so  that      H[d, θ]  =  0  2.  for  each  pixel  that  is  verified  is  an  edge  point e[x,y]    

a.  plot  lines  at  different  angles  and  draw  the  perpendicular  line  that  intersects  the  origin  (θ = 0  to  180° )

b.  calculate  parameters  d and θ for  each  line    c.  increase  the  corresponding  accumulator  bin    H[d, θ]  =  +  1  

 3.  Find  the  value(s)  of  (d, θ)  where  H[d, θ]  is  maximum  4.  The  detected  line  in  the  image  is  given  by  

Page 22: Edges - MICC · • Tracing&edges&& &importantedges&are&along&con*nuous&curves&in&the&image.&Therefore&edges&are&detected&if&the& faintsec*on&of&the&edge&line&is&followed&and&noisy

Example  

Lines  plo>ed  at  different  angles  and  distances  to  the  origin  for  three  dis*nct  points  

angle-­‐distance  plot:  the  intersec*on  point  is  the  H[d, θ]  maximum  and  determines  the  parameters  of  the  line  passing  through  the  three  points