http://ceng.anadolu.edu.tr/cv/edgedrawing/
References
- C. Topal, C. Akinlar, Edge Drawing: A Combined Real-Time Edge and Segment Detector,” Journal of Visual Communication and Image Representation, 23(6), 862-872, 2012.
- C. Topal, C. Akinlar, and Y. Genc, Edge Drawing: A Heuristic Approach to Robust Real-Time Edge Detection, Proceedings of the ICPR, pp. 2424-2427, August 2010.
1. Introduction
A good edge detector must produce high quality edge maps, and it must run very fast. The speed of the detector is especially important for real-time computer vision and image processing applications. Among the existing edge detectors, Canny is generally considered to produce the best results, and is assumed to be the de-facto edge detector by the computer vision and image processing community. OpenCV implementation of Canny (cvCanny function) is the fastest known implementation of this famous edge detector, and is used by many real-time computer vision and image processing applications.
(a)噪聲引起的切口實例和不連續性;(b)無人值守的邊緣形態;(c)Lena’s帽子邊界上的兩個像素寬的邊緣段;(d)未平滑的邊緣段不連續的。
圖1顯示了著名的Lena圖像的邊緣圖,該圖像由opencv Canny獲得,其中一些低質量的邊緣片段已被放大顯示。顯然,邊緣圖本身是低質量的,由邊緣線段組成,其中包括參差不齊的、不連續、無人值守的、多像素寬度的邊緣。這是因為傳統的邊緣檢測器,包括Canny算法,以孤立的和單獨的方式評估像素,通常忽略像素間的關系,從而導致這種不連續性,單個和無人值守的邊緣線段的構成。
對現有邊緣檢測實時性能的應用評價已經清楚地顯示為一種新的邊緣檢測,需滿足以下要求:(1)跑得很快,即實時性,(2)生產高質量的邊緣圖由相干的,連續的,本地化,1個像素寬的邊緣。下面,我們提出邊緣繪制(ED)[ 1 ]作為一種新的非正統的邊緣或邊界檢測算法,滿足這兩個要求。ED不僅與傳統的二值邊緣圖相區別,而且以矢量形式輸出邊緣圖作為一組邊緣段,每個邊緣段由一個連續的像素鏈組成。
2. Edge Drawing algorithm (ED)
ED works on grayscale images and is comprised of four main steps: (1) Suppression of noise by Gaussian filtering. (2) Computation of the gradient magnitude and edge direction maps. (3) Extraction of the anchors. (4) Connecting the anchors by smart routing.
2.1. Gaussian filtering
the very first step of ED is similar to most image processing methods: we convolve the image with a Gaussian kernel to suppress noise and smooth out the image.
For all results given in this paper, a 5 × 5 Gaussian kernel with = 1 is used.
2.2. Computation of the gradient magnitude and edge direction maps
Figure 2 depicts the computation of the gradient magnitude and edge direction maps. Using the smoothed image, we compute the horizontal and vertical gradients, Gx and Gy, respectively.
Any of the well-known gradient operators, e.g., Prewitt, Sobel, Scharr, etc., can be used at this step. The gradient magnitude G at a pixel is then obtained by simply adding Gx and Gy, i.e., G = |Gx| + |Gy|.
Simultaneously with the gradient magnitude map, the edge direction map is also computed by simply comparing the horizontal and vertical gradients at each pixel.
If the horizontal gradient is bigger, i.e., |Gx| >= |Gy|, a vertical edge is assumed to pass through the pixel. Otherwise, a horizontal edge is assumed to pass through the pixel.
So, the gradient angle at a pixel is assumed to be either 0 or 90 degrees. Our experiments have shown that using two gradient angles were enough to smartly route the anchor linking process.
Increasing the number of gradient angles simply increases the computational time without aiding the linking process.
我們的實驗表明,使用兩個梯度角足以巧妙地錨定連接過程。增加梯度角的數目只是增加了計算時間而不幫助連接過程。
Figure 3: (a) Input image Lena, (b)Thresholded image with respect to gradient magnitudes. The Sobel operator and a threshold of 36 were used to obtain this image.
為了幫助我們忽略非邊緣像素並加快計算速度,我們對梯度圖進行閾值化,消除所謂的“弱”像素。
這非常類似於Canny通過低閾值消除弱像素[ 3 ]:回想一下,在計算梯度圖之后,Canny消除了梯度值小於用戶定義的低閾值的像素,這些像素不包含邊緣元素(邊緣像素)。
我們使用相同的想法,並消除那些像素的梯度幅度小於一個特定的用戶定義的閾值。圖3(a)顯示了Lena圖像,圖3(b)顯示相應的閾值梯度圖。
為了獲得這個梯度圖,我們使用Sobel算子和36的梯度閾值。黑色像素是Sobel算子產生小於36的梯度值的所有像素,所有其他像素都被標記為白色。
我們稱之為“邊緣區域”圖像。所有圖像的邊緣像素必須位於邊緣區域的邊界,消除的黑色像素不包含邊緣像素。
2.3. Extraction of the anchors
高斯濾波和梯度圖計算,ED前兩個步驟與大多數邊緣檢測算法相似。邊緣區域的圖像而計算后,ED遵循一個非常非正統的方法:不是測試邊緣區域內的單個像素是否成為邊緣素,
ED first spots a subset of pixels(稱為錨),然后將這些錨連接起來由一個啟發式智能路算法( a heuristic smart routing algorithm)
。直觀地說,錨對應梯度圖的峰(maximas)。如果你在3D中看到梯度圖,錨就會成為山脈的頂點。
(a)Lena’s邊緣圖計算問題,它是一個點到點邊界完成的拼圖。當連續點連接時,我們得到一個高質量的邊緣映射,由干凈的、一個像素寬的、連續的邊緣部分組成;
(b)Lena’s帽子的梯度地圖碎片;
(c)碎片(b)在三維圖。兩個樣品錨用紅色圓圈標記,箭頭表示錨點連接方向。
檢測錨點的算法:
算法1顯示了檢查一個像素(x,y)作為錨的算法。由於錨必須是梯度圖的一個頂點,所以我們只需將像素的梯度值與它相鄰的進行比較。
對於水平邊緣,比較上下鄰居;對於垂直邊緣,比較左和右鄰居。如果像素的梯度值大於其相鄰值通過一定的閾值(ANCHOR_THRESH),此像素標記為錨。
通過改變錨閾值,可以調整錨的數量。此外,錨定測試可以在不同的掃描間隔,即每行/列,每兩行/列等。增加錨的數量將增加邊緣地圖的細節,反之亦然。
我們還注意到,錨提取是一個類屬過程,其他的錨提取方法可以用來代替表1中給出的方法。
圖5(a)顯示了錨閾值為8的Lena圖像的一組錨,以及掃描間隔為4;也就是說,每第四行或列已被掃描以測試錨。掃描每一行和列將產生更多的錨。增加掃描間隔將減少錨的數量。
一般的經驗法則如下:如果請求圖像的所有細節,應該使用1的掃描間隔。如果只請求長的邊緣(即對象邊界的骨架),則可以使用較大的掃描間隔。因此,通過改變這個參數,可以很容易地調整最終邊緣圖中的細節量。
2.4. Connecting the anchors by smart routing
ED的最后一步也是最關鍵的一步是通過連接它們之間的錨來繪制邊緣。由於在這一步中,通過使用算法前三個步驟中收集的信息構造了邊緣圖,因此這一步驟值得特別注意。
連接連續的錨,我們只是從一個高峰(錨)定到下一個走過梯度圖的山脈。這個過程由算法的步驟2中計算的梯度幅度和邊緣方向圖來指導。
The smart routing process works as follows: 從錨點開始,我們查看通過錨的邊緣的方向。如果水平邊緣通過錨點,我們開始連接過程,通過向左和右邊移動(參見圖6(a))。
如果垂直邊緣通過錨點,我們將開始上下移動鏈接過程(參見圖6(b))。在移動過程中,只有3個緊鄰的鄰居被考慮,最大梯度值的一個被選中。
移動在2個條件下停止:
(1)我們離開的邊緣地區,即當前像素的閾值梯度值是0。
(2)我們遇到一個先前檢測到的邊緣像素。
算法2中的算法描述了從錨點(x,y)開始的智能路由(the smart routing procedure)。我們假設一個水平的邊緣通過這個錨,我們給出的算法走左邊的錨。向右、向上或向下都是非常相似的,沒有詳細闡述。
從錨(x,y)開始,只要不滿足上面列出的2個停止條件,我們繼續向左走。在每次循環迭代中,我們只看3個的左邊,即(x-1, y-1), (x-1, y) and (x-1, y+1),選擇一個具有最大梯度值。
如果我們向右走,我們會考慮右面3個相鄰的,即(x + 1,y-1),(x+1,y)和(x + 1,y + 1)。
(a) (b)
Figure 7: (a) An illustration of the smart routing procedure, (b) Detected edge segments for Lena.
在圖7(a)中對閾值梯度地圖區域放大詳細闡述了智能路由的過程。數值代表在像素數的梯度值;黑色像素表示閾值像素。錨點用紅色圓圈標記,鏈接過程中收集的像素用黃色圓圈標記。
假設像素(8,4)是起始錨點。由於水平邊緣是通過這個錨,水平步行(首先向左,然后向右)開始。小箭頭顯示在路由過程中正在考慮的像素,而藍色箭頭表示選定的像素。
如圖所示,在每個迭代中對邊緣方向檢查3個緊鄰鄰居,並且始終選擇具有最大梯度值的像素。
圖5(b)顯示了Lena圖像的ED邊緣圖。顯然,這是一個非常高質量的邊緣地圖的所有細節檢測,由相干的,相鄰的,1像素寬的邊緣構成。ED不僅生成這個二進制邊緣圖,它還生成一組由像素鏈的向量形式組成的邊緣段。
因此,每個這樣的鏈都是一個輪廓,可用於進一步處理以執行對象檢測、跟蹤、注冊等。圖7(b)顯示了Lena檢測的邊緣段,這個邊緣圖有432個部分,每個顏色代表不同的邊緣段。
3.Experiments
在這一部分中,我們比較了ED和opencv實現的著名的Canny邊緣檢測器的性能。我們使用Canny進行比較,因為它被認為在多種圖像產生最好的結果。
OpenCV實現的Canny(cvCanny函數)作為許多實時計算機視覺和圖像處理應用的實際邊緣檢測器。
我們首先介紹一些最具挑戰性的圖像的邊緣圖結果。然后比較這些圖像的ED和opencv的運行時間。
(a) (b) (c)
Figure 8: (a) Original image (512x512), (b) OpenCV Canny edge map for low threshold = 60 and high threshold = 100, (c) ED edge map with Sobel operator, gradient threshold = 36 and anchor threshold = 8.
看得到的邊緣結果圖,我們看到,Canny邊緣圖中含有大量的不相交的,無人管理的噪音邊緣像素(edgels),ED的邊緣圖很干凈,由相干的,連續的,本地化的和1像素寬的邊緣像素構成。
此外,ED的結果作為一組邊緣段返回,每個邊緣段由一個連續的像素鏈組成,如圖7(b)所示。
Figure 9: (Top-to-bottom, Left-to-right) ED’s edge map for scan intervals(掃描間隔) of 8, 16, 32 and 64 respectively. Sobel operator and a gradient threshold of 36 were used to obtain all edge maps.
圖9顯示了錨點對最終邊緣圖的影響。正如我們前面提到的,鏈接步驟中的更多錨會導致更詳細的邊緣圖,反之亦然。在圖9中,錨計算的掃描間隔從8更改為64。具體來說,為了獲得左上角映射,我們在錨計算步驟中掃描每第八行或列。繼續向右和向下,我們分別掃描每第十六,第三十二和第六十四行或列。當錨的數量減少時,最終邊界圖中的細節也減少了。注意,圖像中對象的一般骨架總是被提取出來,只有微小的細節才會丟失。這是因為長邊界上的單個錨足以提取整個邊界。因此,即使我們在對象的長邊界上有很少的錨,ED也能夠在錨連接過程中提取這些長的邊界。
Table 1: Dissection of the running times of ED and OpenCV Canny on four images given in figure 8. The running times were obtained in a PC with a 3Ghz P4 processor and 1 GB RAM.
表1顯示了在圖8所示的四幅圖像上的ED和OpenCV Canny的運行時間的分析。 顯然,ED運行得很實時,幾乎和opencv一樣快。但回想起來,ED不僅生成更好的二值邊緣映射,而且還生成邊緣圖作為邊緣段,每一段都由矢量形式的像素鏈組成。從opencv的二進制邊緣圖中生成像素段作為像素鏈,不僅需要額外的處理,而且由於Canny邊緣映射的噪聲結構,也會產生較差的結果。然而ED,默認情況下,產生的這些輪廓鏈是不需要額外處理的。