1. 程式人生 > >區域增長 (用於分割)

區域增長 (用於分割)

1 Region Growing

區域增長演算法的基本思想:先選擇一個種子區域(通常為一個畫素或一些畫素點),認為這個種子區域是在被分割的物件範圍之內。所選種子區域的鄰域畫素會被計算從而決定它是否包含在該種子區域裡。如果根據某種準則,種子區域的鄰域畫素應該包含進來,則該鄰域畫素會被包含到種子區域中去,然後判斷下一個畫素點,最終種子區域會越來越大,當所有的畫素點判斷完畢,分割結束。

因為區域增長對於噪音很敏感,所以一般的影象都要先進行平滑處理CurvatureFlowImageFilter。

根據判斷畫素點是否位於種子區域內,區域增長演算法主要有如下型別:

1.1 Connected Threshold 連通閾值

基本思想:估算畫素點的灰度值是否在一個指定的範圍內。

類:itk::ConnectedThresholdImageFilter

類itk::ConnectedThresholdImageFilter使用了一種叫做Flood fill iterator的迭代器。在使用這個類時使用者要指定畫素值的最小值lower threshold和最大值upper threshold,畫素值位於lower threshold和upper threshold的畫素會被認為是位於種子區域內。

類itk::ConnectedThresholdImageFilter的輸出是二進位制影象檔案,即除了提取的影象區域外,其他區域的畫素值均為零。提取的影象區域的畫素值可通過方法SetReplaceValue

()函式進行設定。另外還要提供一個種子點對這個類進行初始化,也就是通過方法SetSeed(Index)傳遞該種子的索引值。

缺點:對於不連通的區域,儘管畫素值符合要求,也分割不出來。

輸入: 影象、種子點座標、閾值的最大最小值。

輸出:二值影象

可以新增多個種子點, AddSeed( )

1.2 Otsu Segmentation

Otsu演算法,即大津法,由大津於1979年提出,對影象Image,記t為前景與背景的分割閾值,前景點數佔影象比例為w0,平均灰度為u0;背景點數佔影象比例為w1,平均灰度為u1。影象的總平均灰度為:u=w0*u0+w1*u1。從最小灰度值到最大灰度值遍歷t,當t使得值g=w0*(u0-u)2+w1*(u1-u)2 最大時t即為分割的最佳閾值。對大津法可作如下理解:該式實際上就是類間方差值,閾值t分割出的前景和背景兩部分構成了整幅影象,而前景取值u0,概率為w0,背景取值u1,概率為w1,總均值為u,根據方差的定義即得該式。因方差是灰度分佈均勻性的一種度量,方差值越大,說明構成影象的兩部分差別越大,當部分目標錯分為背景或部分背景錯分為目標都會導致兩部分差別變小,因此使類間方差最大的分割意味著錯分概率最小。

OTSU閾值處理(最大類間方差),演算法步驟如下:  【1】統計灰度級中每個畫素在整幅影象中的個數。  【2】計算每個畫素在整幅影象的概率分佈。  【3】對灰度級進行遍歷搜尋,計算當前灰度值下前景背景類間概率。  【4】通過目標函式計算出類內與類間方差下對應的閾值。

類:itk::OtsuThresholdImageFilter

類itk::OtsuThresholdImageFilter的方法SetOutsideValue()/SetInsideValue()設定位於閾值範圍外/內的畫素值;SetNumberOfHistogramBins()設定用於計算分割閾值的直方圖的灰度級數。

類:itk::OtsuMultipleThresholdsCalculator

類itk::OtsuMultipleThresholdsCalculator的作用主要是輸入一幅影象的直方圖,並且指定要計算的Otsu閾值個數,該類可以計算指定個數的Otsu閾值,使得影象的類間方差(between-class variance)最大。而影象的直方圖可以通過類itk::Statistics::ScalorImageToHistogramGenerator進行計算。

優點:不需要指定種子點

輸入: 影象

輸出:二值影象(可以設定區域內和背景不同的灰度值)

1.3 Neighborhood Connected

類:itk::NeighborhoodConnectedImageFilter

類NeighborhoodConnectedImageFilter與類ConnectedThresholdImageFilter的區別

當一個畫素的灰度值位於使用者定義的灰度值範圍內時,類ConnectedThresholdImageFilter會把它包含到種子區域裡去;只有當一個畫素的一個畫素及其鄰域畫素的灰度值滿足使用者定義的灰度範圍內時,類NeighborhoodConnectedImageFilter才會把這個畫素包含到種子區域中去,鄰域的半徑大小由使用者來設定。

The operation of this filter is equivalent to applying the ConnectedThresholdImageFilter followed by mathematical morphology erosion using a structuring element of the same shape as the neighborhood provided to the NeighborhoodConnectedImageFilter.

The larger the neighborhood, the more stable this filter will be against noise in the input image, but also the longer the computing time will be.

優點: 可以新增多個種子點, AddSeed( )

輸入: 影象、種子點座標、閾值的最大最小值。

輸出:二值影象

1.4 Confidence Connected

類:itk::ConfidenceConnectedImageFilter

基本思想:首先計算當前區域中包含的所有畫素點的灰度值的期望和標準差,根據使用者指定的因子(乘以標準差)計算以期望為中心的灰度值範圍。如果鄰域畫素的灰度值位於這個範圍內的話就被包含進種子區域,否則就被排除。當遍歷了所有的鄰域畫素,即認為迭代完成;再進行下一次迭代過程。下一次迭代時,畫素點的灰度值期望和標準差是以新的畫素區域為基礎進行計算的。

I(X)∈ [m - fσ,m+ fσ]

式中m指灰度值的期望,σ指標準差,f是使用者指定的因子。X是特定的鄰域畫素,I()指代影象。

不同的迭代次數輸出的結果是不同。

1.5 Isolated Connected

類:itk::IsolatedConnectedImageFilter

In this filter two seeds (SetSeed1()/SetSeed2()) and a lower threshold (SetLower()) are provided by the user. The filter will grow a region connected to the first seed and not connected to the second one. In order to do this, the filter finds an intensity value that could be used as upper threshold for the first seed. A binary search is used to find the value that separates both seeds.

This filter is intended to be used in cases where adjacent anatomical structures are difficult to separate. Selecting one seed in one structure and the other seed in the adjacent structure creates the appropriate setup for computing the threshold that will separate both structures.

1.6 Confidence Connected in Vector Images

類:itk::VectorConfidenceConnectedImageFilter

The basic difference between the scalar and vector version is that the vector version uses the covariance matrix (協方差矩陣) instead of a variance (方差), and a vector mean (向量期望) instead of a scalar mean. The membership of a vector pixel value to the region is measured using the Mahalanobis distance as implemented in the class itk::Statistics::MahalanobisDistanceThresholdImageFunction.

原文來自:

我在他的基礎上做了簡單的標註。