Hey.
Welcome back to the course in this chapter.
We're going to take a look at convolutions, the operation that allows us to detect features in images.
So let's get started.
So what exactly is a convolution operation?
Well, a confirmation operation is a mathematical term that describes the process of combining two functions
to produce a tube.
It's quite simple.
It's like any other mathematical operation if you think about it.
However, in our situation with the output we want is called the feature map, and we'll get to future
maps shortly.
Just remember that and we use a matrix called a filter or cuno, which is applied to our image.
So the first function?
Remember, we talked about two functions here.
The first function is our image.
It is then combined or multiplied depending on how you want to describe the operation would convulses
the actual correct term involved with ACCOUNL or filter, and that produces our feature map.
So this is just mathematically what I'm describing here.
It's quite simple concept.
So now let's take a look at a very basic view of the operation.
Imagine this is our input image here.
Imagine it's a binary image, so the ones represent white.
The zeros represent black.
So it's a weird, pretty weird image right now.
Doesn't really represent anything.
And this is our filter colonel.
So hypothetically, we're just multiplying our input image again.
So a filter, which, you know, to produce this output or feature map.
So how does this work?
So just to refresh your memory, remember I said a one was white and the zero was black.
Well, in reality, grayscale images are represented from zero to 255, with 255 being white.
So you can see it's all white here.
And if you look closely, you can see as the values get lower, it turns into different shades of gray.
With these values being pure black, which is probably going to be zero, even this, we can't see it
because it's a black on black font.
But nevertheless, that's how images are shown in this example here.
So this is an actual image, except the values are skilled differently.
OK.
Hope I didn't lose you there.
It's not not.
It's not complicated.
It's quite simple so far.
So let's continue with the convolution operation.
So now let's take a look at the actual mathematics behind the convolution operation.
No, it's not complicated.
It's actually quite simple.
It's just multiplication and addition.
And what I'll show you, I'll step through the first calculation here for you.
The first calculation, what I mean is that I'll show you how we calculate the first top left digit
here off of each map.
So as you can see of overlaid this blue matrix onto here.
So remember that it was one one zero here, zero zero one one zero one.
Those values still remain.
It's one one zero zero zero one one zero one.
However, you can see it's now multiplied by digits here, so you just directly map this across here
to the top left corner of this image of the of our image, and you multiply each one.
So you can step to the calculations.
Have a rule by row here.
It doesn't matter what sequence you would do two additions.
So one by zero plus zero by one plus one by zero here, plus one by one plus zero by zero plus zero
by minus one then plus zero by zero then plus zero by one by one.
And then plus one by zero.
And if you just work, this out might might seem a bit long, but it's not that long.
It's just you might try nine different additions, multiple locations here, and it just gives us two.
So that's how we calculate the two here.
So you can just check it here and can see this.
This rule, this column corresponds to the first column here, and this one corresponds to the middle
column.
And this one corresponds to that column just to Sant'Egidio just to make sure that we're doing this
right.
So how do we get the next digit?
Well, as you may have noticed, we simply shifted.
Let's do this again.
The matrix by one step to the right.
And then we multiply it out just again and we get to value one.
So we're multiplying all these values and selling them individually.
You get the value one.
And then so on.
This gives us a value of minus one.
I just left all the calculations there because it was getting a bit tedious to keep writing.
And then we keep going again, again, again, again, again and again.
And that's how we get our feature map output.
So you can see when we multiply a five by five image matrix here, by a tree by tree kernel, we get
a.
Tree by tree feature map suggests that's important for later.
Little lessons to just keep that in mind.
So what are image features?
So as you as you know, well, as you may not know yet, but I'll tell you, no future maps actually
feature detectors.
So why did we just do this compilation convolution?
Because convolution filters or kernels actually act as feature detectors, so to detect special features
and images?
Take a look at this one.
This convolution filter right here, this one one zero zero zero minus one minus one is actually an
edge detector.
So when you multiply this convolution, this scanner by this image and this image is basically an edge,
it's a square.
I just threw it like a rectangle just for illustrative purposes.
But you can see this is a gray area to talk here you and this is bright white area and you can see when
you multiply this.
Our feature map actually is an edge as well.
You can see that it translates that edge directly.
This means that it worked as an edge to edge the detector here.
And these are some examples of other feature detectors that can be hardcoded here.
However, just so you know in CNN's Our Kernels Aren't Hardcoded, they're initialized at randomly and
see during the training process, it learns the weights of different filters.
So that's the cool part, which we'll get into shortly, but that's a cool part about CNN's.
So these are some examples of basically kernels that were that we extracted from a tree and CNN.
And you can see this one is looking for like this sort of edge pattern.
This one's looking for like almost a stripe.
This one is looking for a horizontal stripe, but someone's looking for a checkerboard pattern.
This one is looking for a pink blob.
So you can see feature detectors being be able to detect many different features.
So imagine you're now using all of these different features combinations of these to detect what a dog
is or cats.
You see how it makes sense now you can see how powerful CNN's are.
So this is an example of just sliding a window across just to get the output of this feature detector
so you can see how it looks and just does it again.
So let's take a look at it.
And that's the feature map it produces from the output.
So how do we calculate the feature map size?
Remember, I said this was a five by five matrix, which you can see here tree by tree kernel, which
you can see here, and a tree by tree output.
But how do you know this size is going to be a tree burial?
But we can have images of many different sizes, as well as many different sized kernels.
So here's a simple formula to get the output size.
It's an NSD dimension of the image here.
Know we.
We assume it's a square images for CNN.
It makes the calculation and process much, much faster, and it doesn't affect anything.
So even if you resize a different aspect ratio image, it still maintains its silkscreen and lens quite
well.
Even if you resize and change the aspect ratio.
So just remember all images and CNN's square images.
And F is the M colonel or filter dimensions, so we have a tree by tree again, it's a square.
And plus one, so we got five minus three plus one gives us three.
And that's that's that's the dimensions of our feature feature map.
So that's it for this lesson.
In the next lesson, we'll spend some time discussing what feature detectors are and how they help us
classify images, which you might already have some suspicion about it now given this lesson.
Thank you, and I'll see you in the next section.