Home page

Deconstructing Deep Learning + δeviations

Drop me an email Format : Date | Title
  TL; DR

Total posts : 86

View My GitHub Profile


Index page

Image kernels

Image kernels are fun as filters, so let us just look at a few of them and maybe try something else?

Where do I get the numbers from? Awesome blog

So we start with this image

drawing

Filters

Blur

kernel_blur = [
0.0625 0.125 0.0625;
0.125 0.25 0.125;
0.0625 0.125 0.0625
]

drawing

Bottom Sobel

kernel_blur = [
-1 -2 -1 ;
0 0 0 ;
1 2 1
]

drawing

Emboss

kernel_blur = [
-2 -1 0 ;
-1 1 1 ;
0 1 2
]

drawing

Identify

kernel_blur = [
0 0 0 ;
0 1 0;
0  0 0
]

drawing

Left Sobel

kernel_blur = [
-1 0 -1 ;
-2 0 -2;
1 0 -1
]

drawing

Outline

kernel_blur = [
-1 -1 -1 ;
-1 8 -1 ; 
-1 -1 -1
]

drawing

Right sobel

kernel_blur = [
-1 0 1 ;
-2 0 2 ; 
-1 0 1
]

drawing

Sharpen

kernel_blur = [
0 -1 0 ;
-1 5 -1 ;
0 -1 0
]

drawing

Top sobel

kernel_blur = [
1 2 1 ;
0 0 0 ; 
-1 -2 -1
]

drawing

Experiments!!

What happens when you convolve two images of the same size??

tmp_cm =  channelview(Gray.(testimage("house")));
tmp_cm2 = channelview(Gray.(testimage("mandrill")));
imshow(conv2d(tmp_cm2,tmp_cm))

I get a fully white image... Is it because the images are of the same size? Since these convolutions are only in black and white.. I cheated a bit for the purpose of this experiment and used a library. (Obviously I will do it from scratch later or atleast try to).

using DSP
imshow(DSP.conv(channelview(tmp_cm),tmp_cm2))

I want to analyze a bit more. Here are the two images drawingdrawing

So I get this. drawing

I am not sure why? I can't visualize it atleast.

Different size?

So the largest realistic kernel size I have seen is 15. So let us take this house and resize it to that and try and see what happens.

drawing

Man I have to take a second to actually appreciate the fact that we can understand this as a house. So this is what we get.

drawing

Wow! That actually did something. You know, I am actually enjoying this detour. I should add more experiment sections whenever I can.