+ All Categories
Home > Documents > CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know...

CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know...

Date post: 15-Mar-2021
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
34
CSCI 497P/597P: Computer Vision Lecture 3: Convolution and its Properties
Transcript
Page 1: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

CSCI 497P/597P: Computer Vision

Lecture 3: Convolution and its Properties

Page 2: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

CSCI 497P/597P: Computer Vision

Lecture 3: Convolution and its Properties

Page 3: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Announcements• HW1 is out today

• Convers filtering and convolution

• Due in 1 week (10pm next Tuesday)

Page 4: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Goals• Understand the distinction between cross-correlation and

convolution.

• Know the properties of cross-correlation and convolution:

• Linearity and shift-invariance (both) Associativity and commutativity (convolution only)

• Understand the design of several common image filters:

• Box blur and Gaussian blur

• Sharpening

• Understand the limitations of linear filtering

Page 5: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Computing Cross-Correlationg = f ⌦ w

<latexit sha1_base64="A2BTYXOmOKiP4ZSUdZvtUXeuNFA=">AAAB+HicbVBNSwMxEM3Wr1o/uurRS7AInsquKHoRil48VrAf0C4lm2bb0GyyJLNKXfpLvHhQxKs/xZv/xrTdg7Y+GHi8N8PMvDAR3IDnfTuFldW19Y3iZmlre2e37O7tN41KNWUNqoTS7ZAYJrhkDeAgWDvRjMShYK1wdDP1Ww9MG67kPYwTFsRkIHnEKQEr9dzyAF/hCHcV8JgZ/NhzK17VmwEvEz8nFZSj3nO/un1F05hJoIIY0/G9BIKMaOBUsEmpmxqWEDoiA9axVBK7Jshmh0/wsVX6OFLalgQ8U39PZCQ2ZhyHtjMmMDSL3lT8z+ukEF0GGZdJCkzS+aIoFRgUnqaA+1wzCmJsCaGa21sxHRJNKNisSjYEf/HlZdI8rfpn1fO7s0rtOo+jiA7RETpBPrpANXSL6qiBKErRM3pFb86T8+K8Ox/z1oKTzxygP3A+fwBIU5I3</latexit>

input image

weights, or filter, or kerneloutput image

for x = 0 to w: for y = 0 to h: for i in -k to k: for j in -k to k: out[x,y] += w[i,j] * in[x+i, y+j]

Page 6: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Computing Cross-Correlationg = f ⌦ w

<latexit sha1_base64="A2BTYXOmOKiP4ZSUdZvtUXeuNFA=">AAAB+HicbVBNSwMxEM3Wr1o/uurRS7AInsquKHoRil48VrAf0C4lm2bb0GyyJLNKXfpLvHhQxKs/xZv/xrTdg7Y+GHi8N8PMvDAR3IDnfTuFldW19Y3iZmlre2e37O7tN41KNWUNqoTS7ZAYJrhkDeAgWDvRjMShYK1wdDP1Ww9MG67kPYwTFsRkIHnEKQEr9dzyAF/hCHcV8JgZ/NhzK17VmwEvEz8nFZSj3nO/un1F05hJoIIY0/G9BIKMaOBUsEmpmxqWEDoiA9axVBK7Jshmh0/wsVX6OFLalgQ8U39PZCQ2ZhyHtjMmMDSL3lT8z+ukEF0GGZdJCkzS+aIoFRgUnqaA+1wzCmJsCaGa21sxHRJNKNisSjYEf/HlZdI8rfpn1fO7s0rtOo+jiA7RETpBPrpANXSL6qiBKErRM3pFb86T8+K8Ox/z1oKTzxygP3A+fwBIU5I3</latexit>

input image

weights, or filter, or kerneloutput image

for x = 0 to w: for y = 0 to h: for i in -k to k: for j in -k to k: out[x,y] += w[i,j] * in[x+i, y+j]

Page 7: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

A bit of practiceIn groups: work on Problems #1-4

• Problems are linked from the course webpage on the Schedule table

• Write answers in your Google Doc (pinned in group Discord channels)

Page 8: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance
Page 9: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Questions remain• What happens at the edges?

• What properties does this operator have?

• What can and can't this operator do?

Page 10: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

A shift filterCross-correlate the image f with the kernel w. Use "same" output size, with zero-padding for out-of-bounds values.

1 2 11 3 10 1 3g = f ⌦ w

<latexit sha1_base64="A2BTYXOmOKiP4ZSUdZvtUXeuNFA=">AAAB+HicbVBNSwMxEM3Wr1o/uurRS7AInsquKHoRil48VrAf0C4lm2bb0GyyJLNKXfpLvHhQxKs/xZv/xrTdg7Y+GHi8N8PMvDAR3IDnfTuFldW19Y3iZmlre2e37O7tN41KNWUNqoTS7ZAYJrhkDeAgWDvRjMShYK1wdDP1Ww9MG67kPYwTFsRkIHnEKQEr9dzyAF/hCHcV8JgZ/NhzK17VmwEvEz8nFZSj3nO/un1F05hJoIIY0/G9BIKMaOBUsEmpmxqWEDoiA9axVBK7Jshmh0/wsVX6OFLalgQ8U39PZCQ2ZhyHtjMmMDSL3lT8z+ukEF0GGZdJCkzS+aIoFRgUnqaA+1wzCmJsCaGa21sxHRJNKNisSjYEf/HlZdI8rfpn1fO7s0rtOo+jiA7RETpBPrpANXSL6qiBKErRM3pFb86T8+K8Ox/z1oKTzxygP3A+fwBIU5I3</latexit>

f w

=0 0 0

0 0 1

0 0 0

Page 11: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

• Cross-correlation:

• Convolution:

Cross-correlation vs Convolution

g(x, y) =kX

i=�k

kX

j=�k

w(i, j)f(x+ i, y + j)

<latexit sha1_base64="ppMYXLOtixgDad+/y4K7xXv0VRA=">AAACI3icbVBdSwJBFJ3t0+zL6rGXIQkUTXbDKAJB6qVHg/wANZkdZ3Xc2Q9mZstl8b/00l/ppYdCeumh/9KoS5R2YODcc+7lzj2mz6iQuv6pLS2vrK6tJzaSm1vbO7upvf2a8AKOSRV7zOMNEwnCqEuqkkpGGj4nyDEZqZv29cSvPxAuqOfeydAnbQf1XGpRjKSSOqnLXmaYD7OwBFsicDoRLZ3Yo/vIHsX14Kd+zND8IAutzDBH82FukO2k0npBnwIuEiMmaRCj0kmNW10PBw5xJWZIiKah+7IdIS4pZmSUbAWC+AjbqEeairrIIaIdTW8cwWOldKHlcfVcCafq74kIOUKEjqk6HST7Yt6biP95zUBaF+2Iun4giYtni6yAQenBSWCwSznBkoWKIMyp+ivEfcQRlirWpArBmD95kdROC0axcHZbTJev4jgS4BAcgQwwwDkogxtQAVWAwRN4AW/gXXvWXrWx9jFrXdLimQPwB9rXN8JMonw=</latexit>

g(x, y) =kX

i=�k

kX

j=�k

w(i, j)f(x� i, y � j)

<latexit sha1_base64="WReDaxTpY1c+rYMm2xmhnyNLFsM=">AAACI3icbVBdSwJBFJ21L7Mvq8dehiRQUNkNowgEqZceDfID1GR2nNVxZz+YmS2Xxf/SS3+llx4K6aWH/kujLlHagYFzz7mXO/eYPqNC6vqnllhZXVvfSG6mtrZ3dvfS+wd14QUckxr2mMebJhKEUZfUJJWMNH1OkGMy0jDt66nfeCBcUM+9k6FPOg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kISPYWOlhgK5QiM7QU69YcsvuDGiZeBkpQYZ6r/jV7UckEVQawrHWHc+NjZ9iZRjhdFLoJprGmIzwgHYslVhQ7aezgyfoxCp9FEbKljRopv6eSLHQeiwC2ymwGepFbyr+53USE176KZNxYqgk80VhwpGJ0PR71GeKEsPHlmCimL0VkSFWmBibUcGG4C2+vEya52WvUq7eVUq16yyOPBzBMZyCBxdQg1uoQwMICHiGV3hzlPPivDsf89ack80cwh84nz+sQ48H</latexit>

These are related:

Page 12: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Properties

Shift invariance (both)

Linearity (both)

Commutativity (conv only)

Associativity (conv only)

Assume: is an image; and are filters; , are scalars.f w v s t

f(x, y) ⊗ w = [ f(x − s, y − t) ⊗ w)](x − s, y − t)

( f ⊗ w) + ( f ⊗ v) = f ⊗ (w + v)( f ⊗ sw) = s( f ⊗ w)

and

f * w = w * f

( f * w) * v = f * (w * v)

Page 13: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

What can we do with this?

Page 14: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

What can we do with this?

000

010

000

<latexit sha1_base64="73rJz0sVedxRxb1nPqaqAz07Rvo=">AAAB7nicbVDLSgNBEOyNrxhfUY9eBoPgKeyKosegF48RzAOSJcxOZpMhszPLTK8QQj7CiwdFvPo93vwbJ8keNLGgoajqprsrSqWw6PvfXmFtfWNzq7hd2tnd2z8oHx41rc4M4w2mpTbtiFouheINFCh5OzWcJpHkrWh0N/NbT9xYodUjjlMeJnSgRCwYRSe1uhpFwm2vXPGr/hxklQQ5qUCOeq/81e1rliVcIZPU2k7gpxhOqEHBJJ+WupnlKWUjOuAdRxV1S8LJ/NwpOXNKn8TauFJI5urviQlNrB0nketMKA7tsjcT//M6GcY34USoNEOu2GJRnEmCmsx+J31hOEM5doQyI9ythA2poQxdQiUXQrD88ippXlSDy+rVw2WldpvHUYQTOIVzCOAaanAPdWgAgxE8wyu8ean34r17H4vWgpfPHMMfeJ8/iIOPtQ==</latexit>

=

Page 15: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

000

010

000

=

Identity filter: output = input

*

What can we do with this?

Page 16: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

What can we do with this?

=000

001

000

*

Page 17: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

What can we do with this?

=000

001

000

left shift

*

Page 18: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

What can we do with this?

=111

111

111

*

Page 19: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

What can we do with this?

=111

111

111

mean filter, or box blur

*

Page 20: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Blurring: Another example

Notice: lattice-like textureWhat motivated the mean filter?

* =

Page 21: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Blurring: Another example

Notice: lattice-like textureWhat motivated the mean filter?Idea: the closer the pixel, the more likely it is to be similar

* =

Page 22: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Gaussian Blur• Idea: weight closer pixels more heavily using a

Gaussian kernel:

This is a bivariate (2D) Gaussian function:

Page 23: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Gaussian Blur• Idea: weight closer pixels more heavily using a

Gaussian kernel:

This is a bivariate (2D) Gaussian function: 3x3 approximation

Page 24: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Gaussian Filters

= 30 pixels= 1 pixel = 5 pixels = 10 pixels

Page 25: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Mean vs. Gaussian

Page 26: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Composing Filters• Recall associativity:

* =

G� ⇤G� = Gp2�

<latexit sha1_base64="7sKsM38nFcd+qu/baOm86FQFTrQ=">AAACEXicbZDLSsNAFIYn9VbrLerSzWARiouSlIpuhKILXVawF2hCmEwn7dDJJM5MhBLyCm58FTcuFHHrzp1v47QNoq0/DHz85xzOnN+PGZXKsr6MwtLyyupacb20sbm1vWPu7rVllAhMWjhikej6SBJGOWkpqhjpxoKg0Gek448uJ/XOPRGSRvxWjWPihmjAaUAxUtryzMqV50g6CBE8hj94rjF15J1QaS2beZlnlq2qNRVcBDuHMsjV9MxPpx/hJCRcYYak7NlWrNwUCUUxI1nJSSSJER6hAelp5Cgk0k2nF2XwSDt9GERCP67g1P09kaJQynHo684QqaGcr03M/2q9RAVnbkp5nCjC8WxRkDCoIjiJB/apIFixsQaEBdV/hXiIBMJKh1jSIdjzJy9Cu1a169WTm3q5cZHHUQQH4BBUgA1OQQNcgyZoAQwewBN4Aa/Go/FsvBnvs9aCkc/sgz8yPr4BM9icqw==</latexit>

Page 27: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Sharpening!?• What gets removed when we blur?

– =

Page 28: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Sharpening!?• What gets removed when we blur?

– =

=+ α

Page 29: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

SharpeningAfterBefore

Page 30: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

=+ α – =( )

Sharpening: once more with mathing

Page 31: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

=+ α – =( )

Sharpening: once more with mathing

Blur kernelscaled impulseLaplacian of Gaussian

Page 32: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

=+ α – =( )

Sharpening: once more with mathing

Blur kernelscaled impulseLaplacian of Gaussian

5 -10

-1-10

0 -1 0Possible 3x3

Approximation

Page 33: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Effects of Sharpening

Page 34: CSCI 497P/597P: Computer Visionwehrwes/courses/csci497p_20f/lectures/L03.pdfconvolution. • Know the properties of cross-correlation and convolution: • Linearity and shift-invariance

Limitations: What can't convolution do?

• Maximum filter?

• Threshold?

• partial derivative?y

Problem #5 - discuss in groups.


Recommended