5
$\begingroup$

I want to ask why everywhere is used to do edge detection in spatial domain and not in frequency domain with FFT of image and apply HP filter. Thank you.

$\endgroup$
0

2 Answers 2

3
$\begingroup$

We need to separate the concept of edge detection from the tools we use to apply the procedure.

Edges are local property of the image. Being so local means we don't analyze the image in frequency domain but in spatial domain.
Yet, a common step for edge detection is applying High Pass / Gradient Filter. Since those are Linear Shift Invariant operators we may apply them according to the Convolution Theorem.

Classic edge detection procedure can be built according to Canny Edge Detector (See Why Is the Canny Edge Detection Used Instead of Sobel / Prewitt Edge Detection Before Hough Transformation):

  1. Apply Low Pass Filter (Usually Gaussian Blur).
    This can be applied in Frequency Domain though it may be faster do in spatial domain.
  2. Apply Gradient (High Pass Filter) / Edge Detector Filter.
    Usually Roberts, Prewitt or Sobel. Also can be applied in frequency domain. A more optimal filter, in my opinion, would be applying the 1st Derivative of Gaussian Filter. Then we can, in one step, apply both the HPF and the LPF (Hence Band Pass Filter).
  3. Extract Magnitude and Direction of Potential Edges.
    Simple analysis of the 2 images of the output of the previous filter. Basically a feature extraction for the next steps.
  4. Thresholding.
    We keep only potential edges where their magnitude was large enough (Above a threshold we set).
  5. Edge Tracking and Hysteresis.
    We use the direction knowledge to go along edges and combine long edges even in the case some parts of it have a magnitude lower than the threshold.

The above is a scheme for a very effective edge detector. Of course we don't implement it manually but use libraries which implemented this and tweaked the implementation.
You may find it in MATLAB's edge() (Under the canny method), OpenCV's cv::Canny and Python SciKit - Image's feature.canny().

As you may see, while some phases of the procedure can be applied in frequency domain, conceptually, edge detection is a process done in spatial domain on local features.

Regarding speed, where to apply what. Have a look at Strategy / Method for Implementation of the Fastest 1D Linear Convolution / Correlation. Though the answer is for 1D it applies for 2D as well. In most cases, since the kernels used above are very small, applying the whole process in spatial domain will be faster. It might be different if you apply the same kernel to many images at once.

$\endgroup$
2
  • $\begingroup$ “applying the 1st Derivative of Gaussian Filter.” This is indeed what the original Canny paper proposes. In popular culture it somehow got split into your steps 1 and 2, not sure why. Maybe because of what filters are available in OpenCV? $\endgroup$ Commented May 20, 2022 at 23:58
  • $\begingroup$ @CrisLuengo, I am not sure when it happened. Not string in history of it (Maybe because I'm relatively new?). You made me learn a fact :-). $\endgroup$
    – Royi
    Commented May 21, 2022 at 6:20
0
$\begingroup$

What you claim is simply not true. One step in edge detection is often a simple high-pass (or band-pass) filter, and those are commonly applied using fast convolution, which is a frequency-domain algorithm.

$\endgroup$
10
  • 1
    $\begingroup$ Then why is everywhere in edge detection posted info about Sobel operator, Perwitt and etc? Is it easier to do it in spatial domain with convolution or what ? I cant find obvious reason to do edge detection only in spatial domain. $\endgroup$
    – Olo
    Commented Dec 8, 2020 at 19:53
  • $\begingroup$ It's easy to explain. It's not easier to do, necessary. For some things it is. For everything nonlinear, it's usually necessary. $\endgroup$ Commented Dec 8, 2020 at 19:54
  • $\begingroup$ So for linear transformation it is necessary to do it in spatial domain? and in nonlinear it can be done in both (freq and spatial)? Thx for ans u helped me so much $\endgroup$
    – Olo
    Commented Dec 8, 2020 at 19:57
  • $\begingroup$ No, exactly the other way around. If something is linear, and you're using a linear transform like the Fourier transform, it can be done in whichever domain is easier/faster/elegant. Non-linear operations don't "translate". $\endgroup$ Commented Dec 8, 2020 at 20:02
  • 1
    $\begingroup$ @MarcusMüller, Since the kernels of Edge Detectors filters are so small an optimized implementation in spatial domain will be faster. So calling DFT Based Convolution Fast Convolution isn't accurate in this case (Also I don't think this is a good term at all). $\endgroup$
    – Royi
    Commented Sep 5, 2021 at 3:25

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.