Halconにおけるドメインとリージョンの機能と操作手法

ドメインの概念

Halconでは、画像のROI(Region Of Interest)を数学的な定義域(Domain)と呼称します。画像は座標を画素値にマッピングする関数f(x)=grayとして定義され、ドメインはこのxの範囲を指します。ドメインは画像の処理対象領域を定義する仕組みです。

画像とリージョンを結合する主要演算子はreduce_domainで、元画像のドメイン範囲を保持します。

ドメイン操作の実装例

元画像: printer_chip/printer_chip_01

2.1 get_domainの利用

元画像の全領域をドメインとして取得します。

read_image (InputImage, 'printer_chip/printer_chip_01')
get_domain (InputImage, FullDomain)

2.2 reduce_domainによる領域抽出

指定領域をドメインに設定し、画像を縮小します。

gen_circle (RegionROI, 520.3, 385.7, 150.2)
reduce_domain (InputImage, RegionROI, CroppedImage)

2.3 complementによる補集合計算

ドメインの補集合を生成します。

complement (RegionROI, ComplementRegion)

2.4 crop_domainによる画像裁断

ドメインの最小外接矩形に画像を裁断します。

crop_domain (CroppedImage, RegionCropped)

2.5 change_domainによるドメイン変更

既存ドメインを新たな領域に置換します。

gen_rectangle1 (NewRegion, 200.5, 150.8, 600.3, 500.2)
change_domain (CroppedImage, NewRegion, UpdatedImage)

リージョンの特性と処理

ドメインは内部的にはリージョン(Region)オブジェクトで表現され、Halconではドメイン型は存在しません。リージョンはランレングス符号化で表現され、ピクセル単位のデータを保持します。

3.1 しきい値によるリージョン生成

画像を二値化してリージョンを抽出します。

threshold (InputImage, ExtractedRegion, 150, 255)
reduce_domain (InputImage, ExtractedRegion, RegionImage)

3.2 リージョンの座標取得

リージョンの座標データを取得します。

get_region_points (ExtractedRegion, PointRows, PointCols)

3.3 リージョンの特徴量計算

リージョンの幾何特性を算出します。

area_center (ExtractedRegion, RegionArea, CenterRow, CenterCol)
circularity (ExtractedRegion, CircularityValue)

3.4 リージョン操作演算子

  • gen_rectangle1: 軸平行矩形の生成
  • gen_circle: 円形リージョンの生成
  • connection: 分離領域を連結
  • fill_up: リージョン内の穴を埋める
  • union1: 複数リージョンを統合

タグ: halcon region domain image-processing computer-vision

5月25日 16:58 投稿