In image processing books , we are told that Images need to be padded while doing filtering in the frequency domain. Why we need that zero padding ?
-
1$\begingroup$ you mean this ? dsp.stackexchange.com/questions/741/… $\endgroup$– Sufiyan GhoriCommented Sep 25, 2012 at 13:28
-
$\begingroup$ I am interested in padding of images, more about the physical significance. $\endgroup$– Prashant SinghCommented Sep 25, 2012 at 13:31
-
2$\begingroup$ @PrashantSingh There is no physical significance. The zero-padding is just a way to make cyclical convolutions (which is what FFT-based convolutions are) act like linear convolutions. $\endgroup$– Jim ClayCommented Sep 25, 2012 at 14:15
2 Answers
Multiplication in the frequency domain corresponds with circular convolution in the spatial domain. This means that without padding the image properly, results from one side of the image will wrap around to the other side of the image.
You can think of 2D filtering as a sliding window that is centered over each pixel in the image and the center output pixel is a weighted sum of the pixels in the window. With circular convolution, when the window hangs over the right edge of the image, it is actually wrapping back around to the left side of the image. This means that output pixels on the right edge of the image will be affected by pixels on the left edge, which is almost never what is actually desired.
Zero-padding allows space for this wrap-around to occur without contaminating actual output pixels.
-
4$\begingroup$ Just a note: you are avoiding wrapping from one side of the image to the other; but you are still introducing a transient between the 0-padded area and the actual image. To minimize this transient, instead of zero padding you can use techniques such as mirroring the actual image onto the padding area. $\endgroup$– JuanchoCommented Sep 25, 2012 at 17:19
Fourier transform is periodic in nature. Periodic function can cause interference between adjacent periods and this will lead to wraparound error.
To overcome this we go for zero padding
-
2$\begingroup$ You're not adding very much material to the original answer... $\endgroup$– MaximGiCommented Feb 22, 2016 at 12:36