1
$\begingroup$

Suppose I was handed a blackbox that I know is either a Convolution filter or Cross-Correlation filter, and my job is to find out which it is.

My idea is to pretend that it's Cross-Correlation and attempt to do Template Matching using an image and a crop of the same image. If the output has a peak where a successful template match would be, it's Cross-Correlation. Otherwise, it's Convolution.

Is this a reliable test? Is it possible to also arrive at the same expected output if the blackbox was actually Convolution?

$\endgroup$

1 Answer 1

1
$\begingroup$

Method#1: Feed input arguments that are asymmetrical:

>> conv(1:3,1:3)

ans =
     1     4    10    12     9   
>> xcorr(1:3,1:3)

ans =    
    3.0000    8.0000   14.0000    8.0000    3.0000

Method#2: Swap inputs and see if the output changes

>> xcorr(1:3,[1 1 1])
ans =
    1.0000    3.0000    6.0000    5.0000    3.0000
>> xcorr([1 1 1], 1:3)
ans =
    3.0000    5.0000    6.0000    3.0000    1.0000
$\endgroup$
2
  • $\begingroup$ great answer. If I could check it, I would. $\endgroup$
    – mark leeds
    Commented Sep 1, 2020 at 1:51
  • $\begingroup$ For images that tend to be real-valued and visual "objects"/templates that tends to be symmetrical, the only functional difference might be a possible flip of the image. $\endgroup$
    – Knut Inge
    Commented Sep 1, 2020 at 7:55

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.