5
$\begingroup$

Usually, for edge detection, we perform smoothing and then pass it through difference filter. What if application of difference filter happens first and then smoothing. How the math behind the same will change?

$\endgroup$
1
  • $\begingroup$ What is the difference of? $\endgroup$ Commented Jul 4, 2020 at 7:45

3 Answers 3

3
$\begingroup$

In the classic framework both the Smoothing and the Difference Filter are applied using Convolution.
Since it is done using convolution it implies the operation is Linear Spatially Invariant (LSI).
LSI operators can be applied in any order and the result will be the same. This is also a result of the commutativity property of the convolution operator.

Let's say $ f $ is the smoothing operator and $ g $ is the difference operator then:

$$ y = f \ast g \ast x = g \ast f \ast x $$

In practice, a more computational efficient way is define $ h = f \ast g = g \ast f $. See Difference of Gaussians.

$\endgroup$
2
$\begingroup$

Classical linear smoothing and discrete differences can also be interpreted as "replacing the value of one pixel by a weighted average of it and its surrounding pixels":

$$ \widehat{p_{(i,j)}} = \sum_{k,l}w_{(k,l)}p_{(k,l)}\,.$$

With averaging, weights $w_{(k,l)}$ often sum to a strictly positive value. With finite differences, weights $w_{(k,l)$ often sum to a small or close to zero value.

Since both are linear operations, they can be combined and iterated (as long as the weights $w_{(k,l)}$ don't change, as discussed in the previous answers). Therefore, the global result remains a weighted average, and can be represented by the very same equation.

Although basic intuition may suggest that it is better to remove noise before differentiating, for invariant and linear operations, there is no difference.

Finally, the formation process of images is often non-linear, thus many image processing tools introduce a non-linear or non-invariant operations: mathematical morphology, median or stack filters, thresholding, etc. Then, smoothing and differentiating don't commute anymore, and the ordering of linear/non-linear operations matters.

$\endgroup$
1
$\begingroup$

If these filters are linear and spatially invariant, then they are commutative (because convolution is). See Royi's answer.

If it's really a difference filter, that's a linear operation, so that part would be fine. "smoothing" can mean a lot of things, so I can't tell you whether it's linear.

$\endgroup$
3
  • 1
    $\begingroup$ Linear is not enough here. Linear operator do not necessarily commute. They must also be Spatially Invariant (Which they are in case they can be represented by convolution) See my answer (We pressed send at the same time). $\endgroup$
    – Royi
    Commented Jul 4, 2020 at 7:30
  • 1
    $\begingroup$ LTI, not just L... oof, need more coffee. $\endgroup$ Commented Jul 4, 2020 at 7:31
  • $\begingroup$ Yes. For Time line it is LTI for Spatial (Images) I think it goes by LSI. $\endgroup$
    – Royi
    Commented Jul 4, 2020 at 9:20

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.