为什么需要进行 edge detection?

  • 从像素进阶到 features
  • edge 意味着变化,而变化意味着信息
什么是 Edge?

  • gradient (梯度) becomes large, and curvature (曲率) becomes small

通常包含几个步骤:

  1. Edge Filtering
  2. Edge Detection
  3. Edge Linking

Prewitt 算子与 Sobel 算子

Prewitt 算子和 Sobel 算子是卷积核,可以有效提取 Gradient 较大的区域

Prewitt 算子:

Prewitt1=[111000111]Prewitt2=[101101101] \text{Prewitt}_1=\begin{bmatrix} -1 & -1 & -1\\ 0 & 0 & 0\\ 1 & 1 & 1 \end{bmatrix}\\ \text{Prewitt}_2=\begin{bmatrix} -1 & 0 & 1\\ -1 & 0 & 1\\ -1 & 0 & 1 \end{bmatrix}

Sobel 算子:

Sobel1=[121000121]Sobel2=[101202201] \text{Sobel}_1=\begin{bmatrix} -1 & -2 & -1\\ 0 & 0 & 0\\ 1 & 2 & 1 \end{bmatrix}\\ \text{Sobel}_2=\begin{bmatrix} -1 & 0 & 1\\ -2 & 0 & 2\\ -2 & 0 & 1 \end{bmatrix}
  • 优势
    • 简单有效
  • 劣势
    • 对噪声敏感
    • 边缘粗细不一致、strength 不一致

Laplacian of Gaussian (LoG)

我们先对图像应用 Gaussian Blur 进行平滑处理以降低 Laplacian 操作对于噪声的敏感性

我们首先对图像进行 Gaussian Blur,式子可以写作

h(r)=exp(r22σ2),r2=x2+y2 h(r)=-\exp\Big(-\frac{r^2}{2\sigma^2}\Big), r^2=x^2+y^2

接着,对 Gaussian Blur 过的图像进行 Laplacian 操作

2h(r)=2hx2+2hy2=r22σ2σ4exp(r22σ2) \nabla^2 h(r)=\frac{\partial^2 h}{\partial x^2}+\frac{\partial^2 h}{\partial y^2}=-\frac{r^2-2\sigma^2}{\sigma^4}\cdot \exp\Big(-\frac{r^2}{2\sigma^2}\Big)

不过真正在计算的时候,我们通常用一个卷积核来近似 LoG 操作,例如

LoG1=[010141010]LoG2=[111181111] \text{LoG}_1=\begin{bmatrix} 0 &-1 &0\\ -1 &4 &-1 \\ 0 &-1 &0 \end{bmatrix}\quad \text{LoG}_2=\begin{bmatrix} -1 &-1 &-1\\ -1 & 8 &-1 \\ -1 &-1 &-1 \end{bmatrix}

Canny Edge Detector