Filter2D with anchor bigger than kernel size

Hello,
I want to shift an image with interpolation.
I am trying to use a filter2D with :

  • anchor for the number of pixel
  • a 2x2 kernel to interpolate between pixels.
    My problem is : filter2D doesn’t like an anchor bigger than the kernel.
    Is there an other way to make it ?

Thank you
Etienne

float ax = floor(dx);
float ay = floor(dy);
cv::Mat kernel(2,2, CV_32F);
kernel = (cv::Mat_(2, 1) << (1. - (dy - ay)), (dy - ay)) * (cv::Mat_(1, 2) << (1. - (dx - ax)), (dx - ax));
filter2D(_avg, tmp, -1, kernel, cv::Point(ay, ax));

use warpAffine() for that, with appropriate interpolation flag.

the appropriate matrix is easily constructed. start with a 3x3 identity matrix, then change the third column to effect translation. or construct a 2x3 matrix directly.


filter2D anchor should usually be inside the kernel’s domain. I don’t know if filter2D tolerates anchors going outside of that.

you can always take the “outside” part of it out of the call, and afterwards pad/move the resulting data with some other operation (copymakeborder or whatever).

I wouldn’t bother with any of this filter2D business if your kernel represents interpolation that is already implemented in warpAffine.

Thank you, I will try.