I want to implement a gradient operator on an image in Matlab. Should I have to pad the image before its implementation? How do I decide which padding to use e.g. whether to use zero-padding or Symmetric padding? How are they differ from each other? I am new to this field of image processing, Can you provide some references to learn this stuff?

  • $\begingroup$ It depends on the context you want to apply it. Is it to solve some optimization problem or just for visualization or farther processing? $\endgroup$
    – Royi
    Dec 9, 2020 at 8:29
  • $\begingroup$ I use it in optimization, for the implementation of total variation (T.V.). Now, it solve. $\endgroup$ Dec 14, 2020 at 18:53

1 Answer 1


Gradients enhances differences. Hence, highly non-smooth padding (like zero-padding) yields higher gradients, as they don't ensure continuity. Symmetric extensions preserve continuity, and anti-symmetric ones are likely to better preserve derivatives. There is a lot of literature on that, for instance in the filter bank domain. Suppose that the edge sample is $x[0]$, you can have whole-sample anti-symmetry or half-sample anti-symmetry:

  • $x[-1] = -x[1]+2x[0] $
  • $x[-1] = x[0] $ and $x[-2] = -x[1]+2x[0] $

This is illustrated in the picture, from the first paper mentioned below. One can find whole-sample (WS) and half-sample (HS) symmetries and anti-symmetries. A lot of image processing operators combine symmetry or anti-symmetry, so those can be useful.

Lifted linear phase filter banks and the polyphase-with-advance representation [JPEG 2000 image coding applications

A couple of pointers:

Recently, unitary FIR filter banks with linear-phase have been completely parameterized by exploiting the eigenstructure of the exchange matrix. This correspondence gives new characterizations of polyphase matrices of filter banks with various types of symmetry on the filters. Using matrix extensions of the well-known hyperbolic and orthogonal lattices, we give a alternative proof for the parameterization of linear-phase unitary filter banks. A complete parameterization of FIR unitary filter banks with each of the different types of symmetries considered (not just linear-phase) is also given. These results can also be used to generate non-unitary filter banks with symmetries, though no completeness results can be obtained. In some cases implicit, and in others explicit parameterization of wavelet tight frames associated with these filter banks are also given. This paper only considers filter banks with an even number of channels. A similar theory can be developed if the number of channels is an odd integer.

Aside, there are many other possible extensions, using constant continuation (or pixel replication), or higher-order (eg linear, polynomial) extrapolations:

  • 1
    $\begingroup$ Thanks for the useful insight of the answer. Can you please share some links for that. $\endgroup$ Jul 11, 2020 at 11:56

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.