Hello. And welcome back to our Image and Video

Processing Class. We have seen very interesting effects

that we can obtain in images just by doing these very, very simple local

neighborhood operations. Let's use this video to see a couple of

additional ones. In particular, we're going to talk about

derivatives. How we implement those derivatives with

local neighborhoods, and what important are, how important are those derivatives

to do very, very interesting effects in images.

So let's dive into that. Here we have a picture.

It's a one dimensional image that has flat, rump, flat and a very, very sharp

jump and flat again. And let's see what happens when we take

the derivatives of this. I have drawn this here.

But before that you might ask yourself, derivatives, that's a continuous

operation. How can we implement that in our

computer? There are many, many ways of doing that.

But let me illustrate a very simple one. If I want to take the derivative of an

image, in the x direction, I can basically write that in discrete

fashion as f, add the pixel x1-fx.

+ 1 - f(x). Very simple.

I just subtract two consecutive pixels. If I want to write the neighborhood

operation. Let's say in a 3x3 that would mean f(x +

1), I have a 1 here, - f(x). I have a minus one here, and I replace as

a zero. So that's basically how I represent that.

I get, a one dimensional derivative in the x direction.

Similarly, I can get a one dimensional derivative in the y direction.

So we see here that, simulated values of this rump, flat, jump and flat.

So we start with flat 6 we have a, decrease in rump,

flat 1 and then a big jump. The first derivative is this first row

that we see here. Very easy to compute following this

operation. We have actually a couple of 0s because

there's no derivative. The values are constant.

Then basically we have a -1, -1 that means that the pixel values are

decreasing in jumps and constant jumps of one.

It's negative, so they are decreasing. And then once again, we have flat.

And then there's a big jump here when we do 6 - 1,

we're going to get 5 and then it flattens out again.

So we already see that considering the first derivative, we can understand that

for example there is a rump, a smooth decline of pixel values and then

there's a big jump. Very interesting with a derivative we can

detect jumps as we expected. Then we can take actually the second

derivative. And once again we can write an explicit

formula and a mask for this second derivative.

So we are going to do this second derivative of our image, once again in

the x direction. And once again there are many ways of

implementing the second derivative but one of them is to take f at x + 1 + f(x -

1) and subtract 2 times f at the actual pixel.

And that's, once again, very simple to do with our, ubiquitous 3x3.

Now we have a -2 here. A 1 and a 1 on each one of the sides

representing these two. And then we have a 0 everyplace else.

if we do that, so that's kind of an addition derivative

to the first derivative. It's a very simple exercise.

We are, have to take derivatives of these.

We could directly apply this to the original one if we want.

But it's easier just to take, you know, continuous pixel subtraction to the next

one. And we see jumps when there are big

changes. So, 0 - 0 is 0.

For example -1 - -1, once again, 0. But when there are changes, we see a

jump. We see 1 here.

We see another here. So the second derivative very clearly

marks when there are big changes in our image.

And that's extremely powerful. We are detecting big changes by doing

derivatives which are, at least in their simplest fashion, implemented with masks

like this one. So let's just continue with this, and see

some of the examples in a second. Here are different masks that compute

different types of derivatives. So I'm going to ask you, look at this

mask, for example, and tell me what is this mask actually computing?

Is it computing the third derivative for example in the x direction?

Is it computing the third derivative in the y direction?

Or is it computing the sum of the derivatives in the first the first

derivatives in the x and y directions? Or is it computing the sum of the second

derivatives in the x and the second derivative in the y direction.

An interesting property. So what is this mask implementing?