# Analyzing 2 2D Kernels Which Approximates a Gaussian Kernel

I'm new to image processing and am working on mask operations.
I was given two kernels A and B, and performed convolutions respectively on an image.
Then, I have to get the difference of output image as a final result. (kernal A - kernal B)
However, I'm wondering

1. What's the meaning of the "minus" operation?
2. Does it equal to a certain kernel?
3. What if I get it reversed by (kernal B - kernal A), the final result would be the same?

Here are the kernel A and B.

• is this homework? Jan 7, 2023 at 21:44
• yeah, is it not appropriate to ask here? Jan 8, 2023 at 11:15
• Not in a way that is asking someone to do your homework for you- but you can show your work and where you are getting stuck Jan 8, 2023 at 11:28
• Jan 8, 2023 at 11:33
• OK, I'll edit my post Jan 8, 2023 at 14:09

If you look at the kernels you'd see they are both approximations of Gaussian Kernel.

So basically their subtraction is the Difference of Gaussian (DoG) kernel.

### Analysis of the Kernels

As one could see, both kernels are symmetric.
If we analyze their singular values, to check for separability, we can see that the 1st kernel is separable while the 2nd is not.

Yet, still the 1st singular value of the 2nd kernel is more than an order of magnitude bigger, so we can analyze their basis vectors to move into 1D analysis.

Looking at their 1D Row / Column filters:

We can see they are almost equivalent except Kernel B has a wider support.

Wider support means lower bandwidth in the context of LPF filters, as their sum is 1.

Hence their subtraction creates a Band Pass Filter:

Since the 2 variants are multiplication by $$-1$$ of each other, they are both the same filter in the magnitude. Since they are applied in an LSI manner, it means also the result will have a negative value of one to each other.

The result isn't surprising as indeed the DoG filter is a BPF filter.

The full code is available on my StackExchange Signal Processing Q86094 GitHub Repository (Look at the SignalProcessing\86094 folder).

To subtract them, rationalize the denominator of the smaller one on the left hand side by multiplying all elements by 3 and dividing by 1/3 so that the multiplier is 1/48 (same as on the right hand side kernel). Then pad out the left one with zeros. Now subtract one from the other, element by element.

The result for (kernel A - kernel B) is:

         0 -1 -2 -1  0
-1  1  2  1 -1
1/48 *  -2  2  4  2 -2
-1  1  2  1 -1
0 -1 -2 -1  0


If you do (kernel B - kernel A), all signs are reversed and the resulting image will have its polarity reversed. Since you have both positive and negative values and have subtracted two Gaussian-like kernels, the result will be a difference of Gaussians (DoG) kernel, which can be a type of edge detection, depending upon the size of the kernels subtracted.