3

I'm currently working on convolution in OpenCV using filter2D function. Almost always I've found the kernel anchored at the center (using the default value of anchor = (-1,-1)).

Are there cases when the kernel needs to be anchored away from the center? What are the benefits of doing so, if any?

There are similar posts on SE (post 1, post 2) but I couldn't get my answer.

Community
  • 1
  • 1
Ruchir
  • 845
  • 2
  • 10
  • 24
  • Consider this: using a 3x3 kernel with the anchor at the top left, you'll get the same result as with the anchor in the center, only shifted up and to the left one pixel. (Except possibly at the border.) – beaker Jul 24 '15 at 18:31

1 Answers1

4

Yes. Mostly if you're using a non-symmetric kernel.

Most of the time people use a kernel that's either a square, a circle, or a Gaussian. In these cases you probably want the anchor to be in the centre.

But there are other uses to filter2D - trying to find the location of certain artefacts. In those cases - the artefact can be located to the, e.g., left of the interesting point. In that case the anchor will be to the right of the kernel (and the kernel will be similar to the artefact you're looking for)

rabensky
  • 2,864
  • 13
  • 18