目錄
Blob分析的基本思想:
Blob分析主要流程:
Blob分析
分割: Binary Threshold
分割: Histogram
分割: 動態閾值
全局閾值與動態局部閾值的比較
形態學處理
連通區域 connetion
形態學算子
特征提取
提取特征 常用相關算子
區域特征: rectangularity
Blob分析的基本思想:
圖像中相關聯物體(前景)的像素可以通過其灰度值來標
識
Blob分析主要流程:
獲取圖像、分割圖像、提取特征

一個簡單的例子(非常理想的情況)
read_image (Image, ’particle’)
threshold (Image, BrightPixels, 120, 255)
connection (BrightPixels, Particles)
area_center (Particles, Area, Row, Column)
Blob分析
threshold 定義
threshold 算子 速度最快使用頻率最高的分 割算法 如果目標體與背景之間存在灰度差,則 threshold 首先被 使用 如果環境穩定,閾值可在離線狀態下一次確定
分割: Binary Threshold
自動地全局閾值的方法
? 多次平滑直方圖
? 尋找峰值
? 峰谷作為閾值
bin_threshold (Image, Region)
分割: Histogram
自動地全局閾值的方法
? 統計直方圖
? 尋找出現頻率最高的灰度值
? 把比最高灰度值小一定灰階值的灰度值作為閾值
gray_histo (Image, Image, AbsoluteHisto,
RelativeHisto)
PeakGray := sort_index(AbsoluteHisto)[255]
threshold (Image, Region, 0, PeakGray-25)
分割: 動態閾值
動態閾值分割
?
很多情況下由于背景不均一,無
法確定全局閾值
?
目標體經常表現為比背景局部亮
一些或暗一些
?
需要通過其鄰域找到一個合適的
閾值進行分割
?
如何確定其鄰域?
可以通過一些平滑濾波算子來確
定鄰域,例如 mean_image
binomial_filter 等
動態閾值分割,其中S為平滑后的輸入圖像
? ?
? x y R g x y s x y t ?

全局閾值與動態局部閾值的比較
動態局部閾值
– 通過均值濾波確定鄰域
– 濾波器mask尺寸大于字符筆畫的寬度
– 選擇所有比其鄰域暗的像素
mean_image (Image, ImageMean, 21, 21)
dyn_threshold (Image, ImageMean,
Region, 15, 'dark')

watersheds_threshold 函數
方法
? 使用傳統的 watersheds 算法
? 通過閾值合并盆地 :
W
B 1
B 2
max( W ? B 1 , W ? B 2 ) ? Threshold

形態學處理
? 分割之后,往往需要對區域做進一步處理才能滿足要求
? 常用形態學相關算子
connection, select_shape, opening_circle, closing_circle,
opening_rectangle1, closing_rectangle1, difference,
intersection, union1, shaps_trans, fill_up
? 高級算子
boundary, skeleton 等
連通區域 connetion
? 閾值分割后,需要提取目標物體,為了提取目標物體不得不先找到連通區域
? 提取連通域的關鍵是領域搜索的類型
? 在 所有的案例中 8 領域法是默認的

形態學算子
? 任意的結構元素
? 任意尺寸的結構元素
? 非常有效的處理
? 巨大的算子集合 : 44 個算子
? 經典算子
? Erosion, dilation, opening, closing
? 高級算子
? top-hat, bottom-hat, hit-or-miss, boundary
? 特殊算子
? Fitting, pruning, thickening, thinning, skeleton

定義
Operator
? union1 : Union of all regions in one variable
? union2 : Unify all regions in the second parameter with each region in the first
parameter
Usage
? Generate regions by combining primitive shapes
? Combine segmentation results

Definition
Operator
? intersection : Intersect each region of the first parameter with the union of
all regions of the second parameter
Usage
? Generate regions by combining primitive shape
? Use as a result those points where two methods return pixels

Operator
? difference : Subtract from all regions of the first parameter the union of all
regions of the second parameter
Usage
? Generate regions by combining primitive shape
? Use as a result those points where one method but not the other one returns
pixels

Operator
? complement : Calculate the complement of each input region
Usage
? Use as a result those pixels which are not part of the segmentation
Note: with set_system the behavior can be controlled
? 'clip_region' on: the difference with the maximum image size is calculated
? 'clip_region' off: only the smart complement is applied

特征提取
特征描述了區域的特有屬性
區域特征 ( 形狀特征 ) 描述了區域的幾何特征,這些特征不依賴
于灰度值
用途:
? 分割后,通過特征提取選擇出所需的目標物體
? 區域分類 , 比如 OCR
? 測量
? 質量檢測
提取特征 常用相關算子
area_center, smallest_rectangle1, smallest_rectangle2,
compactness, eccentricity, elliptic_axis, area_center_gray,
intensity, min_max_gray
Region Feature: Moments

區域特征 : 更多特征
smallest_circle :
Convexity( 凸狀性 ) : 區域面積和凸形外輪廓的比例
Contlength( 長度 ) : 區域邊界長度
Compactness( 緊密度 ) :




區域特征: rectangularity
? 除了圓形和橢圓形外,長方形是一種典型的形狀
? 典型的形狀特征比如比如 roundness, circularity, 或者 compactness 不適用于
選擇長方形
輸入區域
等價長方形
difference

select_shape( Regions : SelectedRegions : Features , Operation , Min , Max : )
read_image(Image,'monkey')
threshold(Image,S1,160,255) connection(S1,S2)
select_shape(S2,Eyes,['area','anisometry'],'and',[500,1.0],[50000,1.7])
disp_region(Eyes,WindowHandle)