DEV Community

Cover image for Convolution
vivekvohra
vivekvohra

Posted on

1 1

Convolution

CONVOLUTION

CONVOLUTION is a mathematical operator “*”.Graphically, it expresses how the 'shape' of one function is modified by the other.

It is applicable only to Linear Time Invariant Systems.

Time Invariant: systems where a shift in input results in an identical shift in output.eg:

Image description

Linear:In simple terms it is a graph between output and input which must be a straight line through the origin without having saturation or dead time.

Image description
For discrete systems, the formula is :

Image description

Image description

https://youtu.be/QmcoPYUfbJ8?si=2CCf64_x9fGl7jx5

In this video, we understand convolution using a great analogy. Suppose we want to find how much smoke burning several matchsticks produce. Here we take a time frame of 5 minutes. Let's define 2 functions:

Smoke function: S(t) - It describes the amount of smoke produced by a single matchstick across time. It might be an exponential decay graph.
Image description

Firework function: F(t)- It describes the number of matchsticks lit per minute.
Let it be a linear function. y = x

  • t=0 1 match was lit
  • t=2 2 matches were lit: total smoke = smoke from 2 sticks at present = 2*S(0) (because for matchsticks at this time they just started burning) + smoke of prev. 1 stick after 1 sec. of burning = 1*S(1). Image description
at minute 0 1*S(0)
at minute 1 2*S(0)+ 1*S(1)
at minute 2 3*S(0) + prev(t + 1)

Thus we can conclude that it indeed follows the above equation.

We can visualize convolution as a sliding window:

Image description

Image description

Image description

Image description

Now if are 1st function is very large as compared to our 2nd function

Our visualization will be somewhat like this:

Image description

In 2-D version(Image processing)

Image description

or using Alternate illustration :

In the 2-D function, we can solve this Matrix convolution at (2,2) by flipping and multiplying.

i.e. = (i*1)+(h*2)+(g*3)+(f*4)+ (e*5) + (d*6) + (c*7) + (b*8) + (a*9)

In Image Processing, the 2nd function is known as Kernel which is in this case 3x3 matrix

[1/9, 1/9, 1/9],

[1/9, 1/9, 1/9],

[1/9, 1/9, 1/9]

We could have solved our Blur function by taking our 2nd function such that it sum of all nodes is 1 and then doing the convolution. (Remember while multiplying we have to flip the Matrix!!).

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay