Skip to content

openingOpeningOpeningopeningopening🔗

説明🔗

openingOpeningOpeningopeningopening — 領域のオープニング処理を実行する。

書式🔗

opening( region Region, region StructElement, out region RegionOpening )void Opening( const HObject& Region, const HObject& StructElement, HObject* RegionOpening )static void HOperatorSet.Opening( HObject region, HObject structElement, out HObject regionOpening )def opening( region: HObject, struct_element: HObject ) -> HObject

Herror opening( const Hobject Region, const Hobject StructElement, Hobject* RegionOpening )

Herror T_opening( const Hobject Region, const Hobject StructElement, Hobject* RegionOpening )

HRegion HRegion::Opening( const HRegion& StructElement ) const

HRegion HRegion.Opening( HRegion structElement )

説明🔗

openingOpening 操作は、Minkowsi 和を伴う 収縮処理とし て定義されます。openingOpening を領域に適用することによって、より 大きい構造はほとんどがそのままで、ラインや点のような小さい構造は除 去されます。逆に、closingClosing 操作は、小さいギャップを保持する かまたは埋めます。(closingClosing を参照)

openingOpening は、小さい領域 ( StructElementstructElementstruct_element より小さ い) を除去し、領域の境界をなめらかにします。 オープニング操作が参照点の選択には依存しないので、 StructElementstructElementstruct_element の位置は意味をもちません。

構造要素(StructElementstructElementstruct_element)は、 ~ gen_circleGenCircle、 ~ gen_rectangle1GenRectangle1、gen_rectangle2GenRectangle2、 gen_ellipseGenEllipse、draw_regionDrawRegion、 gen_region_polygonGenRegionPolygon、gen_region_pointsGenRegionPoints などのオペ レーターを使用して生成できます。

実行情報🔗

実行情報
  • マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)

  • マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)

パラメーター🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

オープニング処理する対象領域

StructElementstructElementstruct_element (input_object) region → objectHObjectHRegionHObjectHobject

構造要素(位置不変量)

RegionOpeningregionOpeningregion_opening (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

オープニング処理された領域

例🔗

(HDevelop)


* Large regions in an aerial picture (beech trees or meadows):
read_image(Image,'forest_road')
threshold(Image,Light,160,255)
gen_circle(StructElement,100,100,10)
* selecting the large regions
opening(Light,StructElement,Large)
* Selecting of edges with certain orientation:
read_image(Image,'fabrik')
sobel_amp(Image,Sobel,'sum_abs',3)
threshold(Sobel,Edges,10,255)
gen_rectangle2(StructElement,100,100,3.07819,20,1)
opening(Edges,StructElement,Direction)
(C)
/* simulation of opening */
my_opening(Hobject In, Hobject StructElement, Hobject *Out)
{
  Hobject  H\;
  erosion1(In,StructElement,&H,1)\;
  minkowski_add1(H,StructElement,Out,1)\;
}

/* Large regions in an aerial picture (beech trees or meadows): */
read_image(&Image,"forest_road")\;
threshold(Image,&Light,160.0,255.0)\;
gen_circle(&StructElement,100.0,100.0,10.0)\;
/* selecting the large regions */
opening(Light,StructElement,&Large)\;

/* Selecting of edges with certain orientation: */
read_image(&Image,"fabrik")\;
sobel_amp(Image,&Sobel,"sum_abs",3)\;
threshold(Sobel,Edges,30.0,255.0)\;
gen_rectangle2(&StructElement,100.0,100.0,3.07819,20.0,1.0)\;
opening(Edges,StructElement,&Direction)\;
(C++)
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#include "HalconCpp.h"

main()
{
  HImage     img("forest_road")\;
  HWindow    w\;
 cout << "Example: Large regions in an aerial picture: " << endl\;
  cout << "Beech Trees or Meadows" << endl\;
 /* Struct elements */
  HRegion      circ1  = HRegion::GenCircle (10, 10, 10)\;
  HRegion      rect1  = HRegion::GenRectangle2 (100, 100, 3.07819, 20, 1)\;
 /* Segmentation, opening () -> select large regions */
  HRegionArray regs   = (img >= 160).Connection()\;
  HRegionArray open   = regs.Opening (circ1)\;
                       img.Display (w)\;    w.Click ()\;
  w.SetColor ("red")\;   regs.Display (w)\;   w.Click ()\;
  w.SetColor ("green")\; open.Display (w)\;   w.Click ()\;
 cout << "Example: Selecting of edges with certain orientation" << endl\;
 HByteImage hbi ("fabrik")\;
 HImage  sobel = hbi.SobelAmp ("sum_abs", 3)\;
  regs = (sobel >= 30).Connection ()\;
 HRegionArray direc = regs.Opening (rect1)\;
                       hbi.Display (w)\;    w.Click ()\;
  w.SetColor ("red")\;   regs.Display (w)\;   w.Click ()\;
  w.SetColor ("blue")\;  sobel.Display (w)\;  w.Click ()\;
  w.SetColor ("green")\; direc.Display (w)\;  w.Click ()\;
 return(0)\;
}

複雑性🔗

入力領域の面積を \(F1\) とし、構造要素の面積を \(F2\) とします。 その場合、1 つの領域に対する実行時間は以下のようになります。

\[\begin{eqnarray*} O(2 \cdot \sqrt{F1} \cdot \sqrt{F2}) \enspace . \end{eqnarray*}\]

結果🔗

openingOpening は、すべてのパラメーターが正しい場合に 2 (H_MSG_TRUE) を返し ます。 空または入力領域がない場合の動作は、次の設定に従います。

  • 領域がない場合: set_system('no_object_result',<RegionResult>)

  • 領域が空の場合: set_system('empty_region_result',<RegionResult>)

そうでない場合、例外処理が発生します。

他のオペレーターとの組み合わせ🔗

組み合わせ

前処理の候補

thresholdThreshold, regiongrowingRegiongrowing, connectionConnection, union1Union1, watershedsWatersheds, class_ndim_normClassNdimNorm, gen_circleGenCircle, gen_ellipseGenEllipse, gen_rectangle1GenRectangle1, gen_rectangle2GenRectangle2, draw_regionDrawRegion, gen_region_pointsGenRegionPoints, gen_region_polygon_filledGenRegionPolygonFilled

後処理の候補

reduce_domainReduceDomain, select_shapeSelectShape, area_centerAreaCenter, connectionConnection

他の選択候補

minkowski_add1MinkowskiAdd1, erosion1Erosion1, opening_circleOpeningCircle

関連項目

gen_circleGenCircle, gen_rectangle2GenRectangle2, gen_region_polygonGenRegionPolygon

モジュール🔗

Foundation