5
$\begingroup$

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.

enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ is this homework? $\endgroup$ Jan 7, 2023 at 21:44
  • $\begingroup$ yeah, is it not appropriate to ask here? $\endgroup$
    – Nightysky
    Jan 8, 2023 at 11:15
  • 1
    $\begingroup$ 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 $\endgroup$ Jan 8, 2023 at 11:28
  • $\begingroup$ See meta.stackoverflow.com/questions/334822/… $\endgroup$ Jan 8, 2023 at 11:33
  • 1
    $\begingroup$ OK, I'll edit my post $\endgroup$
    – Nightysky
    Jan 8, 2023 at 14:09

2 Answers 2

1
$\begingroup$

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

enter image description here

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.

enter image description here

Looking at their 1D Row / Column filters:

enter image description here

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:

enter image description here

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).

$\endgroup$
2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.