http://www.cnblogs.com/xiaomaLV2/archive/2011/11/29/2267498.html
Blob分析(Blob Analysis)是對圖像中相同像素的連通域進行分析,該連通域稱為Blob。Blob分析可為機器視覺應用提供圖像中的斑點的數量、位置、形狀和方向,還可以提供相關斑點間的拓撲結構。
4.1 Basic Concept
【Blob Analysis --Blob 分析】Blob分析主要分三部分:
文章图片
4.2 Extended Concept
文章图片
4.2.5 Extract Segmentation Parameters獲取分割參數 Instead of using ?xed threshold values, they can be extracted dynamically for each image. One example
for this is a gray value histogram that has multiple peaks, one for each object class. Here, you can use
the operators gray_histo_abs and histo_to_thresh. 如果圖像的前景和背景區域灰度值分布比較均勻,那麼圖像的灰度直方圖具有明顯的雙峰。 我們可以通過圖像的灰度直方圖的谷底值來作為劃分閾值。
gray_histo_abs and histo_to_thresh.
文章图片
4.2.6 Segment Image For the segmentation various methods can be used. The most simple method is threshold, where one
or more gray value ranges that belong to the foreground objects are speci?ed. Another very common
method is
dyn_threshold. Here, a second image is passed as a reference. With this approach, a local
threshold instead of a global threshold is used. These local threshold values are stored in the reference
image. The reference image can either be static by taking a picture of the empty background or can be
determined dynamically with smoothing ?lters like mean_image. dyn_threshold : Segment ->Thresthold->dyn_threshold 算子的例子很好的說明了。 4.2.7 Process Region Once blob regions are segmented, it is often necessary to modify them, e.g., by suppressing small areas,
regions of a given orientation, or regions that are close to other regions. In this context, the morpho-
logical operators opening_circle and opening_rectangle1 are often used to suppress noise and
closing_circle and closing_rectangle1 to ?ll gaps.
Blobs with a speci?c feature can be selected with select_shape, select_shape_std, and se-
lect_shape_proto. 圖像分割以後 opening_circleopening_rectangle1
用於消除噪點 closing_circle and closing_rectangle1 用於填充缺口 也可以根據特征選擇,在halcon 可視化的 特征直方圖中 有操作。 例子:solution_guide/basics/crystal.hdev
文章图片
*中值濾波 濾波用的元素結構大小 21*21
mean_image(Image,ImageMean,21,21)
*兩幅圖像 比較後出來的的二值圖 是要提取的物體
dyn_threshold(Image,ImageMean,RegionDynThresh,8,'dark')
connection(RegionDynThresh,ConnectedRegions)
*改變形狀 為(convex)凸 形
shape_trans (ConnectedRegions, ConvexRegions, 'convex')
*選出面積大的
select_shape (ConvexRegions, LargeRegions, 'area', 'and', 600, 2000)
select_gray (LargeRegions, Image, Crystals, 'entropy', 'and', 1, 5.6) ---------------------------------------------------------------------------------------------------------------------------------------- 例子:solution_guide/basics/atoms.hdev
文章图片
gauss_image (Image, ImageGauss, 5)
watersheds (ImageGauss, Basins, Watersheds)*分水嶺分割 ****** * -> skip regions at the border of the image 去掉四邊 ****** * 以左上角列為基准,選取2--width-1 的列; 也就是說去掉了最左邊的邊框 select_shape (Basins, SelectedRegions1, 'column1', 'and', 2, Width-1)
select_shape (SelectedRegions1, SelectedRegions2, 'row1', 'and', 2, Height-1)
select_shape (SelectedRegions2, SelectedRegions3, 'column2', 'and', 1, Width-3)
select_shape (SelectedRegions3, Inner, 'row2', 'and', 1, Height-3) * -> select irregularly shaped atoms 找到不規則的網格
select_shape (Inner, Irregular, 'compactness', 'and', 1.45, 3) 例子:hdevelop/Applications/Measuring-2D/particle.hdev
文章图片
************************ *提取出白色的區域: 可以看出 分兩部分:1.亮度大的大塊區域 2.亮度小的小塊區域 ************************* *二值化分割說大塊的區域 threshold (Image, Large, 110, 255) *做一下膨脹
dilation_circle (Large, LargeDilation, 7.5) *取出LargeDilation之外的區域,這個區域包含有亮度較小的塊
complement (LargeDilation, NotLarge)
reduce_domain (Image, NotLarge, ParticlesRed) *做中值處理,31*31 較大所以較小的 亮度點就沒了
mean_image (ParticlesRed, Mean, 31, 31) *這兩幅圖做運算,就出來 亮度小的小塊區域
dyn_threshold (ParticlesRed, Mean, SmallRaw, 3, 'light') *再去小噪點 ok
opening_circle (SmallRaw, Small, 2.5)
connection (Small, SmallConnection) 例子:hdevelop/Applications/Measuring-2D/?n.hdev
文章图片
*********************************** *找出圖片的毛刺 *********************************** *二值化 bin_threshold (Fin, Dark) *背景
difference (Fin, Dark, Background) *填充背景圖的缺口 closing_circle (Background, ClosedBackground, 250) *兩背景比較得出 毛刺區域 difference (ClosedBackground, Background, RegionDifference) *消除小的噪點
opening_rectangle1 (RegionDifference, FinRegion, 5, 5) 常用的操作符:見Solution——guide 4.4