Lecture 3

Announcements

Goals

Differentiating Images

Images are functions; differentiation is an operator. What does it mean?

Since they're functions of two variables, a single-valued output needs to be a partial derivative:

We have discrete (i.e., sampled) images, so we need to approximate this with finite differences. Let's design a convolution kernel that accomplishes this.

Whiteboard: calculus reminder

Homework Problem 1

Consider the following two candidate horizontal derivative filters. $$ \begin{bmatrix} 1 & -1 & 0\\ \end{bmatrix} $$

$$ \begin{bmatrix} 1 & 0 & -1\\ \end{bmatrix} $$
  1. Why is the negative number to the right of the positive one?
  2. If we wanted to accurately calculate the slope with correct scale, how would we need to modify the above kernels?
  3. What are the relative merits of each of these filters?

Look at filtering.py

Let's look at the intensities along a single scanline. This one is a vertical scanline that crosses the brick pattern.

This motivates an idea: blur the noise so that the real edges stick out!

Why use 2 filters when you could use just 1?

Homework Problem 2

Compute the following convolution, which results in a new filter kernel, and describe the effect of this new kernel in words. $$ \begin{bmatrix} 1 & 2 & 1\\ 2 & 4 & 2\\ 1 & 2 & 1 \end{bmatrix} * \begin{bmatrix} 0 & 0 & 0\\ 1 & 0 & -1\\ 0 & 0 & 0 \end{bmatrix} = \begin{bmatrix} \ & \ & \ \\ \ & \ & \ \\ \hspace{1em} & \hspace{1em} & \hspace{1em} \end{bmatrix} $$

Let's check our work:

For whatever reason, this is more often written scaled down by 1/2:

From sobel to edge detection

Direction-independent edge detector? First pass: gradient magnitude

$$ \Delta f = \begin{bmatrix} \frac{\partial}{\partial x} f \\ \frac{\partial}{\partial y} f \end{bmatrix} $$

Edge strength: gradient magnitude $||\Delta f||$

This is useful enough that I wrote filtering.grad_mag to make it simple to do.

Classical fancier method: Canny Edge Detector

Spatial Frequency

Whiteboard - intuition (only) for the Fourier decomposition

Introducing: the Frequencyometer(TM)

A very imprecise way of talking about what spatial frequencies are present in an image.

Definitions: "Low-Pass" and "High-Pass" filters

Low-pass: allows low frequencies to pass through unaffected, i.e., attenuates high frequencies.

High-pass: allows high frequencies to pass through unaffected, i.e., attenuates low frequencies.

Question that didn't make it onto the homework: in what sense is Sobel not truly a high-pass filter?

Homework Problems 3-6

(3) Using the language of "low-" and "high-frequency" image content, explain why sharpening is not the inverse of blurring, and what it accomplishes instead.

(4) Consider the original image of beans on the left, and the processed version on the right. Describe what has changed in terms of frequency content.

(5) What's the maximum frequency (expressed in full periods per pixel) representable in a 1D image (i.e., a row of pixels)? What does such an image look like?

(6) What's the minimum frequency representable in a 1D image? What does such an image look like?

Break, if we haven't already taken one!

Downsampling

My image is too big to fit on my screen. For example, suppose beans is 600x600, but I want to display the image in 300x300 pixels. What should I do?

Homework Problem 7

If you walked far away from the above image until you couldn't distinguish individual pixels, what would it look like?

Whiteboard: downsampling freqeuncyometer

Upsampling

My image is too small for my screen. For example, suppose beans is 150x150, but I want to display the image in 600x600 pixels. What should I do?

See naive version preimplemented in filtering.up_2x

Whiteboard: Filtering view of upsampling