edge detection

来源:互联网 发布:天猫淘宝京东的区别ppt 编辑:程序博客网 时间:2024/05/22 12:20

The ideal case for edge will have a deep change, and the 1st derivation can be used for detecting purpose with looking for big absolute values, but in real word, ramp edges exist, well, the 2nd derivation produce a sign change, which can also be used for edge detection, shown as below.

这里写图片描述

However, it is not perfect in real world, some noise makes the trouble, the derivation operations on the contray amplify the noise.

这里写图片描述

So, usually, smothing is applied first before edge detection. Some edge detector(fileter) is designed to integrate the smothing element.
Edge detection is fundamental related to the gradient of the image. That is,

F=FxFyF=[F(x+1,y)F(x,y)F(x,y+1)F(x,y)]

The magnitude and orientation of pixel (x,y) is defined as,
M(x,y)=(Fx)2+(Fy)2

A(x,y)=atanFxFy

We can do things like,
M(x,y)>τ

|A(x,y)θ|<τ1,and,M(x,y)>τ2

The second equation can get the line of θ angle in the image.

Here briefly introduce three types edge detector(filter)s: sobel filter, LoG detector, canny detector.
1. Sobel filter

这里写图片描述

2. LoG detector(Laplacian of Gaussian)
The sobel filter has only one set of scale, by contrast, LoG can be tuned to detecting different scale of edges, LoG has the form as,

2G(x,y)=2x2G(x,y)+2y2G(x,y)=x2+y22σ2σ4ex2+y22σ2

The negative of LoG has the shape like this, and the σ parameter controls the body width of the function.

这里写图片描述

In LoG, 1) The Gaussian smooths the image down to a certain scale; 2) Laplacian finds edges at that scale; 3) LoG will look for zero-crossing of LoG operation since it is like a 2nd derivative. In matlab, function “fspecial” with “log” parameter works for it.

We can approximate the LoG with a difference of Gaussians(DoG), which is used a lot in computer vision(like SIFT)

DoG(x,y)=12πσ21ex2+y22σ2112πσ22ex2+y22σ22,σ1>σ2

3. canny detector
The basic steps of canny detector include:
1) Smooth image with a Gaussian;
2) Compute M(x,y),A(x,y);
3) Apply non-maxima suppression to M(x,y) to obtain a new gradient image gN(x,y)
the basic idea is to quantize A(x,y) into 4 bins, if M(x,y) is greater than both its neighbors in the quantized edge direction, gN(x,y)=M(x,y), otherwise gN(x,y)=0
4) Detect and link edges

gH(x,y)=gN(x,y)τH

gL(x,y)=τLgN(x,y)<τH

respectively for strong and weak edges detection.
and the final map is gH(x,y) {all pixels in gL(x,y) that are adjacent to at least one pixel of gH(x,y)}
The canny edge detector usually has the cleaner result.

All three types edge detector can be realized with function “edge” in matlab.

原创粉丝点击