1. 程式人生 > >matlab之watershed分水嶺分割演算法

matlab之watershed分水嶺分割演算法

Separating touching objects in an image is one of the more difficult image processing operations. The watershed transform is often applied to this problem. The watershed transform finds "catchment basins"(集水盆) and "watershed ridge lines"(山脊線) in an image by treating it as a surface where light pixels are high and dark pixels are low.

如果影象中的目標物體是連線在一起的,則分割起來會更困難,分水嶺分割演算法經常用於處理這類問題,通常會取得比較好的效果。分水嶺分割演算法把影象看成一幅“地形圖”,其中亮度比較強的區域畫素值較大,而比較暗的區域畫素值較小,通過尋找“匯水盆地”和“分水嶺界限”,對影象進行分割。

Segmentation using the watershed transform works better if you can identify, or "mark," foreground objects and background locations. Marker-controlled watershed segmentation follows this basic procedure:

直接應用分水嶺分割演算法的效果往往並不好,如果在影象中對前景物件和背景物件進行標註區別,再應用分水嶺演算法會取得較好的分割效果。基於標記控制的分水嶺分割方法有以下基本步驟:

1. Compute a segmentation function. This is an image whose dark regions are the objects you are trying to segment.

1.計算分割函式。影象中較暗的區域是要分割的物件。

2. Compute foreground markers. These are connected blobs of pixels within each of the objects.

2.計算前景標誌。這些是每個物件內部連線的斑點畫素。

3. Compute background markers. These are pixels that are not part of any object.

3.計算背景標誌。這些是不屬於任何物件的畫素。

4. Modify the segmentation function so that it only has minima at the foreground and background marker locations.

4.修改分割函式,使其僅在前景和後景標記位置有極小值。

5. Compute the watershed transform of the modified segmentation function.

5.對修改後的分割函式做分水嶺變換計算。

Use by Matlab Image Processing Toolbox

使用MATLAB影象處理工具箱

注:期間用到了很多影象處理工具箱的函式,例如fspecial、imfilter、watershed、label2rgb、imopen、imclose、imreconstruct、imcomplement、imregionalmax、bwareaopen、graythresh和imimposemin函式等。

轉載自:http://blog.sina.com.cn/s/blog_725866260100rz7x.html