lab nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/files/535/imagepyramids.pdf · a look at...

27
Lab Nov 8th

Upload: others

Post on 25-Feb-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

Lab Nov 8th

Page 2: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

template matchingtemplate matching

• Problem– Search over entire imageg

• If image / template are large, slow

• |template|*|image| pixel comparisons|template| |image| pixel comparisons

– Rotation invariance

Si e in ariance– Size invariance

– many cases – very slow!!!

• also true for other image processing techniquesg p g q

Page 3: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

a look at complexitya look at complexity

• Ex 1– 1024x768 image = 786432 pixels    80x80 template   =  6400 pixels

• = >5 billion pixel comparisons• =  >5 billion pixel comparisons

• Ex 2– 512x384 image = 196608 pixels 40x40 template = 1600 pixels512x384 image   196608 pixels    40x40 template   1600 pixels

• = 314 million pixel comparisons

• 256x192 image with 20x20 template = 19 million comparisons256x192 image with 20x20 template   19 million comparisons

• 128x96 with 10x10 = 1.2 million

Each step has a factor of 16x speedup. Level1‐4 = 4096X speedup

Page 4: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

image pyramidg py

Page 5: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• Many, many ways…

• size invariant‐– same size template over image pyramidsame size template over image pyramid

Page 6: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• Many, many ways…

• size invariant‐– same size template over image pyramidsame size template over image pyramid

• Is this better/worse than resizing template?

Page 7: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• Many, many ways…

• size invariant‐– same size template over image pyramidsame size template over image pyramid

• Is this better/worse than resizing template? Better!

Page 8: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space

Page 9: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

Page 10: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g

Page 11: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g

Page 12: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

Page 13: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

– repeat

Page 14: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

– repeat

Page 15: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

– repeat

Page 16: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

– repeat

Page 17: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

– repeat

Page 18: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• 1. scale template with image

• Compare template with image…p p g– Look at subregions only using next

templatep

– repeat

Page 19: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• Only smallest image, and circled regions, were searched

Page 20: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• Only smallest image, and circled regions, were searched

• similar technique can be done for any filter – low quality on

low‐res version, then high

on limited regionson limited regions

Page 21: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• Only smallest image, and circled regions, were searched

• similar technique can be done for any filter – low quality on

low‐res version, then high

on limited regionson limited regions

• What kinds of problems 

does this introduce?

Page 22: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

how can we use it?how can we use it?• prune search space• Only smallest image, and circled regions, were searched

• similar technique can be done for any filter – low quality on

low‐res version, then high

on limited regionson limited regions

• What kinds of problems 

does this introduce?– Miss at early level could ruin the

detection

Page 23: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

implementationhow to make pyramid

• Just take every 2L pixel..

• [ 0 1 4 6 7 2 5 1 2 1 1 ][ 0 1 4 6 7 2 5 1 2 1 1 ] 

• [ 0 4 7 5 2 1 ]

• [ 0 7 2 ]

• [ 0 2][ 0 2]

Page 24: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

implementationhow to make pyramid

• or every 3L pixel.. Or XL

• [ 0 1 4 6 7 2 5 1 2 1 1 ][ 0 1 4 6 7 2 5 1 2 1 1 ] 

• [ 0 6 5 1]

• [ 0 1 ]

• No extra memory required. Very fast

Page 25: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

implementationhow to make pyramid

• or every 3L pixel.. Or XL

• [ 0 1 4 6 7 2 5 1 2 1 1 ][ 0 1 4 6 7 2 5 1 2 1 1 ] 

• [ 0 6 5 1]

• [ 0 1 ]

• No extra memory required. Very fast

• Can easily lose features– (nearest neighbour problems)(nearest neighbour problems)

Page 26: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •

implementationhow to make pyramid

• Generate pixel by smoothing (gaussian)

• [ 0 1 4 6 7 2 5 1 2 1 1 ][ 0 1 4 6 7 2 5 1 2 1 1 ] 

• [ 0 4 7 5 2 1 ]

• [ 0 7 2 ]

• [ 0 2][ 0 2]

Page 27: Lab Nov 8th - cs.umanitoba.cacs.umanitoba.ca/~young/Files/535/imagePyramids.pdf · a look at complexity • Ex 1 – 1024x768 image = 786432 pixels 80x80 template = 6400 pixels •