I am trying to implement the constrained least squares filtering as described in Rafael C. Gonzalez, Richard E. Woods - Digital Image Processing 3rd Edition Section 5.9. The equation (5.9-4) says that $ P \left( u, v \right) $ is the Fourier transformation of the Laplacian filter ($ 3 x 3 $). But the coordinates $u$, $v$ are the coordinates of the image which is much greater than 3x3.

How can I implement this 2D Filter in Frequency Domain?

enter image description here

  • $\begingroup$ Could you link to the reference? $\endgroup$
    – Royi
    Nov 7, 2020 at 8:43
  • $\begingroup$ So it's the book Rafael Gonzalez et.al 'Digital image processing 2007, chapter 5.9 p.380 in that edition of the book $\endgroup$ Nov 7, 2020 at 18:28
  • $\begingroup$ Could you post more context about the problem being solved and then I will be able to solve it for you? $\endgroup$
    – Royi
    Nov 8, 2020 at 6:01
  • $\begingroup$ Do you want me to solve it? $\endgroup$
    – Royi
    Nov 9, 2020 at 5:06
  • $\begingroup$ Hi i manage to solve it. Mainly the case is that the filter had to be shifted to the midle of the image and then padded to the size of image. In Matlab fft2(fftshift(o,d1,d2)) where d1 and d2 are dimensions of the img $\endgroup$ Nov 10, 2020 at 6:12

1 Answer 1


When dealing with applying a 2D convolution in frequency domain we have to take into account 2 things:

  1. Extending the kernel to the dimension of the input data.
  2. Dealing with the implicit periodic extension of the frequency domain element wise multiplication.

As you wrote in the comments, one way to do it is simple zero padding and fftshift(). Yet this might cause some artifacts.

Better way to deal with it is the Periodic Extension as I wrote in my answer to Applying 2D Image Convolution in Frequency Domain with Replicate Border Conditions in MATLAB. I added there some code to apply the extension in MATLAB.

More sources would be Applying Image Filtering (Circular Convolution) in Frequency Domain and my answer to How to Zero Pad in Order to Perform Filtering in the Fourier (Frequency) Domain? and 2D Frequency Domain Convolution Using FFT (Convolution Theorem).


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.