# Edge Detection ## Using first order derivative - Look for extrema - For a 2D function, the first derivative and it's kernel are $[-1, 1]$ as $\frac{\partial f(x, y)}{\partial x} \cong f(x, y)-f(x-1, y)$ - Sobel, Prewitt, Roberts operators $\left(\frac{\partial}{\partial x}, \frac{\partial}{\partial y}\right)$ - $1^{\text {st }}$ derivative of Gaussian $ \left(\frac{\partial G}{\partial x}, \frac{\partial G}{\partial y}\right) $ ![[derivativeofgaussian.jpg]] ## Using second order derivative - Look for zero-crossings - The second derivative and its kernel becomes $[1, -2, 1]$ as $\begin{aligned} \frac{\partial^{2} f(x, y)}{\partial x^{2}} & \cong[f(x+1, y)-f(x, y)]-[f(x, y)-f(x-1, y)] \\ &=f(x+1, y)-2 f(x, y)+f(x-1, y) \end{aligned}$ - 2nd directional derivative (Laplacian) - 2nd derivative of Gaussian ![[laplacian-of-gaussian.jpg]] ### Laplace of Gaussian (LoG) $ \nabla^{2} f=\frac{\partial^{2} f}{\partial x^{2}}+\frac{\partial^{2} f}{\partial y^{2}} $ ![[LoG-2D.jpg]] ### Difference of Gaussians (DoG) Laplacian of Gaussian (LoG) can be approximately computed as Difference of Gaussians (DoG). ![[DoG.jpg]] ### Problem with noisy image If we directly use derivative filter on a noisy image, we won't have a good edge. Therefore, always smooth the image first, generally using [[Image Filtering#Gaussian filter]]. ![[edge detection.jpg]] ## Canny Edge Detector It is a statistically optimal edge detector. One of the most successful edge detection method. - Makes use of Derivative of Gaussian - Thinning edges (called non-maximum suppression) - Thin multi-pixel wide "ridges" down to single pixel - Optimal thresholding - Accept all edges over low threshold if they are connected to edge over high threshold - Matlab: `edge (I, 'canny', sigma)` --- ## References