lecture’3:’edge’detec-on’ - cornell university · 2015-01-31 ·...

41
Lecture 3: Edge detec-on CS4670/5670: Computer Vision Kavita Bala From Sandlot Science

Upload: others

Post on 12-Jul-2020

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Lecture  3:  Edge  detec-on    

CS4670/5670:  Computer  Vision  Kavita  Bala  

From Sandlot Science

Page 2: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Announcements  

TexPoint  fonts  used  in  EMF.    Read  the  TexPoint  manual  before  you  delete  this  box.:  AAA

•  Find  partners  on  piazza  

•  PA  1  will  be  out  on  Monday  

•  Quiz  on  Monday  or  Wednesday,  beginning  of  class  

Page 3: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Why  edges?  

TexPoint  fonts  used  in  EMF.    Read  the  TexPoint  manual  before  you  delete  this  box.:  AAA

•  Humans  are  sensi-ve  to  edges  •  Convert  a  2D  image  into  a  set  of  curves  

–  Extracts  salient  features  of  the  scene,  more  compact  

Page 4: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Origin  of  Edges  

•  Edges  are  caused  by  a  variety  of  factors  

depth discontinuity

surface color discontinuity

illumination discontinuity

surface normal discontinuity

Page 5: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Images  as  func-ons…  

•  Edges  look  like  steep  cliffs  

Page 6: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Characterizing  edges  

•  An  edge  is  a  place  of  rapid  change  in  the  image  intensity  func-on  

image  intensity  func-on  

(along  horizontal  scanline)   first  deriva-ve  

edges  correspond  to  extrema  of  deriva-ve  Source:  L.  Lazebnik  

Page 7: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

•  How  can  we  differen-ate  a  digital  image  F[x,y]?  – Op-on  1:    reconstruct  a  con-nuous  image,  f,  then  compute  the  deriva-ve  

– Op-on  2:    take  discrete  deriva-ve  (finite  difference)  

1 -1

How  would  you  implement  this  as  a  linear  filter?  

Image  deriva-ves  

-1

1 :   :  

Source:  S.  Seitz  

Page 8: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

The  gradient  points  in  the  direc-on  of  most  rapid  increase  in  intensity        

Image  gradient  •  The  gradient  of  an  image:    

The  edge  strength  is  given  by  the  gradient  magnitude:    

 

 

The  gradient  direc-on  is  given  by:  

•  how  does  this  relate  to  the  direc-on  of  the  edge?    

Source:  Steve  Seitz  

Page 9: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Image  gradient  

Source:  L.  Lazebnik  

Page 10: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Effects  of  noise  

Where  is  the  edge?  Source:  S.  Seitz  

Noisy  input  image      

Page 11: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Solu-on:  smooth  first  

f

h

f * h

Source:  S.  Seitz  To  find  edges,  look  for  peaks  in  

Page 12: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science
Page 13: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

•  Differen-a-on  is  a  convolu-on  •  Convolu-on  is  associa-ve:  •  This  saves  us  one  opera-on:  

Associa-ve  property  of  convolu-on  

f

Source:  S.  Seitz  

Page 14: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

2D  edge  detec-on  filters  

Gaussian  deriva-ve  of  Gaussian  (x)  

Page 15: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science
Page 16: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Deriva-ve  of  Gaussian  filter  

x-­‐direc-on   y-­‐direc-on  

Page 17: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science
Page 18: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science
Page 19: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

The  Sobel  operator  •  Common  approxima-on  of  deriva-ve  of  Gaussian  

– A  mask  (not  a  convolu-on  kernel)  

-1 0 1

-2 0 2 -1 0 1

1 2 1

0 0 0 -1 -2 -1

•  The  standard  defn.  of  the  Sobel  operator  omits  the  1/8  term  –  doesn’t  make  a  difference  for  edge  detec-on  

–  the  1/8  term  is  needed  to  get  the  right  gradient  magnitude  

Page 20: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Sobel  operator:  example  

Source:  Wikipedia  

Page 21: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Ques-ons?  

Page 22: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Image  Resampling  

CS4670:  Computer  Vision  

Page 23: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Image  Scaling  

This  image  is  too  big  to  fit  on  the  screen.    How  can  we  generate  a  half-­‐sized  version?    

Source:  S.  Seitz  

Page 24: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Image  sub-­‐sampling  

Throw  away  every  other  row  and  column  to  create  a  1/2  size  image  

-­‐  called  image  sub-­‐sampling  

1/4

1/16

Source:  S.  Seitz  

Page 25: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Image  sub-­‐sampling  

1/4    (2x  zoom)   1/16  (4x  zoom)  

Why  does  this  look  so  cruiy?  

1/2  

Source:  S.  Seitz  

Page 26: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Image  sub-­‐sampling  

Source:  F.  Durand  

Page 27: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Even  worse  for  synthe-c  images  

Source:  L.  Zhang  

Page 28: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

What  is  aliasing?  

•  What  if  we  “missed”  things  between  the  samples?  •  Simple  example:  undersampling  a  sine  wave  

–  unsurprising  result:  informa-on  is  lost  

–  surprising  result:  indis-nguishable  from  lower  frequency  

–  also  was  always  indis-nguishable  from  higher  frequencies  

–  aliasing:  signals  “traveling  in  disguise”  as  other  frequencies  

28  

Page 29: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Wagon-­‐wheel  effect  

(See  hnp://www.michaelbach.de/ot/mot_wagonWheel/index.html)  Source:  L.  Zhang  

Page 30: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Aliasing  

•  Occurs  when  your  sampling  rate  is  not  high  enough  to  capture  the  amount  of  detail  in  your  image  

•  Can  give  you  the  wrong  signal/image—an  alias  •  To  do  sampling  right,  need  to  understand  the  structure  of  

your  signal/image  •  Enter  Monsieur  Fourier…  •  To  avoid  aliasing:  

–  sampling  rate  ≥  2  *  max  frequency  in  the  image  •  said  another  way:  ≥  two  samples  per  cycle  

–  This  minimum  sampling  rate  is  called  the  Nyquist  rate  Source:  L.  Zhang  

Page 31: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Nyquist  limit  –  2D  example  

Good sampling

Bad sampling

Page 32: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Aliasing  

•  When  downsampling  by  a  factor  of  two  – Original  image  has  frequencies  that  are  too  high  

•  How  can  we  fix  this?  

Page 33: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Gaussian  pre-­‐filtering  

G 1/4

G 1/8

Gaussian 1/2

•  Solu-on:  filter  the  image,  then  subsample    

Source:  S.  Seitz  

Page 34: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Subsampling  with  Gaussian  pre-­‐filtering  

G 1/4 G 1/8 Gaussian 1/2

•  Solu-on:    filter  the  image,  then  subsample  

Source:  S.  Seitz  

Page 35: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Compare  with...  

1/4 (2x zoom) 1/8 (4x zoom) 1/2

Source:  S.  Seitz  

Page 36: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Gaussian  pre-­‐filtering  •  Solu-on:  filter  

the  image,  then  subsample    

blur  

F0      H  *  

subsample   blur   subsample   …  F1  

F1      H  *  

F2  F0  

Page 37: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

blur  

F0      H  *  

subsample   blur   subsample   …  F1  

F1      H  *  

F2  F0  

{ Gaussian  pyramid  

Page 38: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Gaussian  pyramids    [Burt  and  Adelson,  1983]  

 •  In  computer  graphics,  a  mip  map  [Williams,  1983]  •  A  precursor  to  wavelet  transform    Gaussian  Pyramids  have  all  sorts  of  applica-ons  in  computer  vision  

Source:  S.  Seitz  

Page 39: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Gaussian  pyramids    [Burt  and  Adelson,  1983]  

 •  How  much  space  does  a  Gaussian  pyramid  take  compared  to  the  original  image?  

Source:  S.  Seitz  

Page 40: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Gaussian  Pyramid  

Page 41: Lecture’3:’Edge’detec-on’ - Cornell University · 2015-01-31 · Lecture’3:’Edge’detec-on’ ’ CS4670/5670:ComputerVision KavitaBala From Sandlot Science

Ques-ons?