2
$\begingroup$

Why do we leave two rows and two columns of an image (or) padding zeros to an image for detect edges while using Sobel's operator and Prewitt's operator?

$\endgroup$
  • $\begingroup$ Please make a better title. Something like "zero-padding for edge detection" would actually describe the problem! $\endgroup$ – Marcus Müller Dec 1 '16 at 8:59
1
$\begingroup$

The Sobel Filter is a $ 3 \times 3 $ matrix (it is separable, but let's ignore that).

The anchor pixel is the middle one hence to evaluate the operator on pixels on the upper row the operator needs data above them.
Same goes for pixels on the last row, left-most column or right-most column.

This is usually solved by padding the image (I actually use "Replication" instead of Zero Padding).

Another option is to set the output to be smaller image by not evaluating the extreme rows or columns.

$\endgroup$
  • $\begingroup$ Wow, I had so many typos :-). Thank you for the edit. $\endgroup$ – Royi Dec 3 '16 at 22:19
0
$\begingroup$

Zero padding IS not required, per se. However, rooting on a $3\times 3$ square kernel, pixels on the borders lack neighbors for their derivative estimation. So you have to, either

  • use a shorter derivative estimator on borders (which does not make assumptions regarding side effects) use: zeropzdddigs, symmetric/antisymmetric, periodic or mirror extensions
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.