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.
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):
- Apply Low Pass Filter (Usually Gaussian Blur).
This can be applied in Frequency Domain though it may be faster do in spatial domain.
- 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).
- 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.
We keep only potential edges where their magnitude was large enough (Above a threshold we set).
- 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
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.