So hello and welcome to this demo session. I am Siddhant Ranade.
Hi, I am Meghasyam. In this demo session, we will be talking a bit about image processing.
So an image is basically a set of pixels. So it's basically a matrix in which you
have some numbers inside. So when we talk about a black and white image,
a black and white image has, you know, colour as white, black and shades in between of black.
So white is 255, black is 0 and any other number in between 0 and 255 it's a shade of grey.
So when we look at a black and white image,
it's a set of pixels so it's a matrix in which the numbers are from 0 to 255.
And, if it's a colour image that we are talking about then instead of that being a single matrix,
you have three channels so basically, it's a three dimensional matrix where each channel
represents, each channel stores values from 0 to 255 and you have three such channels
and each channel represents one of the three colours red, green and blue.
So, there are various ways of storing this but RGB is one of the standard ways.
So each of these channels as we call them shows one of the layers and each channel has a grey scale image in it.
So, if you have just Instagram or you know,
any other photo editing software, you would have seen filters like blur, motion blur or sharpen image.
So these are results of convolving the image which we have with the convolution matrix.
So, this is a practical use of convolution, so we'll talk about how this convolution matrix works.
So let's say we have a small image, you know, a four cross four image, it looks something like this.
So this image is basically white in between and surrounded by dark pixels and with a little grey here.
And let's say we have a convolution matrix which looks like this, a three cross three convolution matrix. Ok.
Now let's say, we have a convolution matrix which looks this.
Now, how do we go about applying this matrix on this?
So let's apply this matrix on say this pixel over here.
So, we centre the centre of the matrix on this pixel, so let's do that.
I am just taking out three cross three, you know, boundary across that pixel.
And, I am placing this matrix, a top of this,
so and what we do is, we multiply the corresponding elements, you know, and add all of them together.
So what we eventually get is, since all these are zeroes, only this will contribute, so we'll get 255 out of here.
Now this is the same value but if you look at this pixel over here,
so, if we apply this matrix on this pixel we'll get zero, I mean this is the one which will be filtered out.
So this matrix basically resides in the picture or the matrix shifting a point to the left, a pixel to the left.
We'll show the, you know, the graphical representation of this shortly in a demo,
and let's say, you also have how do we introduce blur in the picture.
You know, what a blur is something like,
you have your camera and then you have shaky hands so you take an image, you see that the image is a bit blurred,
its not sharp, so how do you, you know, give an example of how this blur occurs?
Let's just take a look at it.
Let us take a slightly different image from last time.
So we have except, the image is same except for the particular pixel over here which is 250.
And let's apply this convolution matrix on this pixel over here.
So we'll multiply the corresponding elements this, this and, you know, so the sum would be, you know,
the rest are all zeroes only so these two get picked up, which is 255 plus 255, which is 510, but this is out of bounds.
Our pixel values are supposed to be from 0 to 255 only.
So, why is this happening?
This is happening because we haven't normalized this convolution matrix.
So normalization is basically, you know, take the sum of all these values in between and just 1/sum.
Here the sum is 1 plus, you know, zero, zero, zero and 1, so it's 2.
So, when you normalize this, the resultant value will also be into half, which is 255, which is, you know, in bounds.
So, yeah, that's basically a convolution matrix and normalization.
Now, what this matrix does is, it introduces a blur.
We'll see more of this in the demo, which will happen shortly.
So, you might ask, why this is a blur?
So it is a blur because if you look at it carefully, it is just two shifting matrices.
So, if you had, if you only had that 1 in the top left corner and zero everywhere else,
so it in effect it would be shifting your image to the right and downwards and if you only had 1 in the bottom right corner,
you'd be shifting your image upwards and to the left.
And, if you take these two images and you superimpose them, so you take these two images
and you sort of take the average of the two values that is corresponding pixels, so in effect, you are mixing pixels.
So, if you mix pixels, it is a blur.
So that's basically how you get a blur.
So, we'll see a demo of this thing happening now.
So now here, we have a standard, you know, the chessboard.
Let's apply the, the blur which we were talking about. So this is the blur.
Now, ok, I apply the blur a few times because the image is a huge image and, you know, just mixing two nearby pixels over here.
So let's just compare the blurred image, see the blurred image with the original image.
You can see that, you know, the edges are a bit, you know, away from what they are supposed to be
and let's just talk about the shift also, which I just said.
This shifts the image by just one pixel as you can see,
I am just keep on applying the shift filters, you can see that the image is moving towards the left so that's the shift.
And there are lot of convolution things also.
This is basically the identity filters, it's just nothing, because it just takes the pixel at which the convolution matrix is centred.
And, this is a Gaussian Blur.
Now, which basically blurs the image as such another different way.
So, you can see the difference between both of them.
Let's load the standard test image, which, you know, one of the standard test images, it's called Lena.
And this convolution matrix over here, it sharpens the image which is like you can see what it does exactly.
So, I'll just compare both of them, so you can now clearly see that, you know, the sharp
end edges are highlighted as such here, so the image is a bit more sharp.
That's what when you use the camera, photo editing software and as such,
this is a edge detection filter it does what it exactly says, it detects the edges in the image,
so you can see, you know, the hat, the hair here, the hat, the hair, you can see the eyes also, the elbow.
And this was a demo which we did in MAT LAB.
You also can use many open source photo editing softwares, we'll just take an example of one of those.
It's called GIMP.
So, we have the, ok, the Koala image here.
So people, you can download GIMP, its for free.
Download GIMP, load your test image, whatever you want then go to filters and then go to Generic and then you will have the convolution matrix there.
So, yeah, you can play around with this, it's a five cos five convolution matrix.
I just want to show the blur image here.
And now you can see, I am not normalizing this thing here.
Ok, so it just has 1 and 1, I am not normalizing this thing.
So you can see what happens if I don't normalize it.
So, you know, the pixels get added and they are walled off at 255.
So, you see, its losing most of the information in the image.
So, let's go back to the filters.
The same thing except, I'll normalize the filter this time but, you know, the image is already bad.
Let's just go back to the image. This is the original image.
And, then yeah, this time I'll normalize the filter.
Convolution matrix will have the same things, except I am normalizing it this time. So, I'll just put an ok.
So, you can see the image has, you know, shifted a bit downwards and has a blur because it's the identity and the shifted image added together.
So, yeah, people you can play around with this in GIMP.
So, yes people, you can play around in GIMP, make your own software in SYLAB, MATLAB.
Yeah, you can play around and I'd like to see more of this discussion happening on the discussion forums.
Thank you very much. Yeah, thank you.