2
$\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$
  • $\begingroup$ What is the difference of? $\endgroup$ – Olli Niemitalo Jul 4 at 7:45
1
$\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.

| improve this answer | |
$\endgroup$
0
$\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.

| improve this answer | |
$\endgroup$
  • 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 Jul 4 at 7:30
  • 1
    $\begingroup$ LTI, not just L... oof, need more coffee. $\endgroup$ – Marcus Müller Jul 4 at 7:31
  • $\begingroup$ Yes. For Time line it is LTI for Spatial (Images) I think it goes by LSI. $\endgroup$ – Royi Jul 4 at 9:20
0
$\begingroup$

Classical linear smoothing and 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)}\,.$$

Since this a linear operation, they can be combined and iterated (as long as the weights $w_{(k,l)}$ don't change, as discussed in the previous answers), and the global result remains a weighted average. Basic intuition may suggest that it is better to remove noise before differentiating, yet 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.

| improve this answer | |
$\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.