Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

This exercise does not need Python.

Consider the image

x=(11001100)x = \begin{pmatrix} 1 & 1 & 0 & 0 \\ 1 & 1 & 0 & 0 \end{pmatrix}
  • Calculate by hand the convolution of xx with h1=(1−1)h_1=\begin{pmatrix}1 & -1\end{pmatrix}.

  • Calculate by hand the convolution of xx with h2=(1−1)Th_2=\begin{pmatrix}1 & -1\end{pmatrix}^T.

  • Calculate by hand the convolution of xx with h3=(121)h_3=\begin{pmatrix}1 & 2 & 1\end{pmatrix}.


Correction

Objectives

  • Know how to calculate a convolution product.

  • Interpret a simple convolution.

The convolution is commutative: f1=h1∗x=x∗h1f_1 = h_1 * x = x * h_1 and is defined as:

f1(y,x)=∑m∑nx(y−m,x−n)h1(m,n)f_1(y,x) = \sum_m \sum_n x(y-m,x-n) h_1(m,n)

To apply the convolution product, it is necessary to define an origin in the images h1h_1 and xx. Suppose that the origin is given by the red pixel:

x=(11001100)andh1=(1−1).x = \begin{pmatrix} \color{red}{1} & 1 & 0 & 0 \\ 1 & 1 & 0 & 0 \end{pmatrix} \quad\text{and}\quad h_1=\begin{pmatrix}\color{red}{1} & -1\end{pmatrix}.

Note that h1h_1 has only two non-zero pixels: h1(0,0)=1h_1(0,0)=1 and h1(0,1)=−1h_1(0,1)=-1. Then we have:

f1=(?0−10?0−10)f_1 = \begin{pmatrix} ? & 0 & -1 & 0 \\ ? & 0 & -1 & 0 \end{pmatrix}
Proof

Consider the first pixel (0,0)(0,0):

f1(0,0)=∑m∑nx(0−m,0−n)h1(m,n)f_1(0,0) = \sum_m \sum_n x(0-m,0-n) h_1(m,n)

Because hh has only two non-zero pixels, we have:

f1(0,0)=x(0−0,0−0)×h1(0,0)+x(0−0,0−1)×h1(0,1)=x(0,0)×h1(0,0)+x(0,−1)×h1(0,1)=1×1+?×−1= ?\begin{align*} f_1(0,0) &= x(0-0,0-0) \times h_1(0,0) + x(0-0,0-1) \times h_1(0,1) \\ &= x(0,0) \times h_1(0,0) + x(0,-1) \times h_1(0,1) \\ &= 1 \times 1 + ? \times -1 \\ &= \ ? \end{align*}

The pixel (0,0)(0,0) of f1f_1 cannot be calculated because it needs the value x(0,−1)x(0,-1) which is not defined.

In the same way, we have:

f1(0,1)=x(0−0,1−0)×h1(0,0)+x(0−0,1−1)×h1(0,1)=1×1+1×−1=0\begin{align*} f_1(0,1) &= x(0-0,1-0) \times h_1(0,0) + x(0-0,1-1) \times h_1(0,1) \\ &= 1 \times 1 + 1 \times -1 \\ &= 0 \end{align*}
f1(0,2)=x(0−0,2−0)×h1(0,0)+x(0−0,2−1)×h1(0,1)=0×1+1×−1=−1\begin{align*} f_1(0,2) &= x(0-0,2-0) \times h_1(0,0) + x(0-0,2-1) \times h_1(0,1) \\ &= 0 \times 1 + 1 \times -1 \\ &= -1 \end{align*}
f1(0,3)=x(0−0,3−0)×h1(0,0)+x(0−0,3−1)×h1(0,1)=0×1+0×−1=0\begin{align*} f_1(0,3) &= x(0-0,3-0) \times h_1(0,0) + x(0-0,3-1) \times h_1(0,1) \\ &= 0 \times 1 + 0 \times -1 \\ &= 0 \end{align*}

We obtain similar results fot the second row of ff.

As well, considering that 1 is the pixel at the origin in h2h_2, we obtain:

f2=(????0000),f_2 = \begin{pmatrix} ? & ? & ? & ? \\ 0 & 0 & 0 & 0 \end{pmatrix},

and, considering that 2 is the pixel at the origin in h3h_3, we obtain:

f2=(?31??31?).f_2 = \begin{pmatrix} ? & 3 & 1 & ? \\ ? & 3 & 1 & ? \end{pmatrix}.