Skip to content

pouringPouringPouringpouringpouring🔗

説明🔗

pouringPouringPouringpouringpouring — 「pouring water」(水を注ぎ込むような方式)により画像を分割する。

書式🔗

pouring( image Image, out region Regions, string Mode, integer MinGray, integer MaxGray )void Pouring( const HObject& Image, HObject* Regions, const HTuple& Mode, const HTuple& MinGray, const HTuple& MaxGray )static void HOperatorSet.Pouring( HObject image, out HObject regions, HTuple mode, HTuple minGray, HTuple maxGray )def pouring( image: HObject, mode: str, min_gray: int, max_gray: int ) -> HObject

Herror pouring( const Hobject Image, Hobject* Regions, const char* Mode, const Hlong MinGray, const Hlong MaxGray )

Herror T_pouring( const Hobject Image, Hobject* Regions, const Htuple Mode, const Htuple MinGray, const Htuple MaxGray )

HRegion HImage::Pouring( const HString& Mode, Hlong MinGray, Hlong MaxGray ) const

HRegion HImage::Pouring( const char* Mode, Hlong MinGray, Hlong MaxGray ) const

HRegion HImage::Pouring( const wchar_t* Mode, Hlong MinGray, Hlong MaxGray ) const (Windows only)

HRegion HImage.Pouring( string mode, int minGray, int maxGray )

説明🔗

pouringPouring は、入力画像を「山脈」とみなします。より大きな グレイ値が山頂に対応し、より小さいグレイ値が谷底に対応します。 pouringPouring は、いくつかのステップで入力画像を分割します。最初 に、局所最大部、すなわちそれらの隣り合うもの (4-連結性内で) よりも大きいグレイ値をも つ単独のピクセル、あるいは拡張されたピクセ ル群が抽出されます。次のステップでは、このように見つけられた 局所最大部が、「谷底」に到達するまで展開する際の開始点となります。展開 は、(局所最大部分からすべての方向に下り坂を流れる水のように)グレイ値が より小さくなるピクセル鎖が存在する限り行われます。再び、より弱い条 件(より小さいあるいは等しい)で 4-連結性が使用されます。このこと は、谷底における点が 1 つ以上の、局所最大部に属するかもしれないことを意味 します。これらのエリアは、最初は領域に割り当てられずに、最後 のステップにおいてすべての競合するセグメント間を分離します。この分 離は、すべての曖昧なピクセルが割り当てられるまで、すべての セグメントの均一な展開によって行われます。パラメーター Modemodemode は、どのステップが実行されるのかを決定します。以下に 示す値に設定部可能です。

  • 'all'"all" これは、操作の標準モードです。分割のすべてのステップが実行され ます。領域は最大値に割り当てられ、重なり合った領域は分割されま す。

  • 'maxima'"maxima" 分割は、入力画像の局所最大値のみを抽出します。対応する領域は、 抽出されません。

  • 'regions'"regions" 分割は、入力画像の局所最大値と一意に特定される対応する領域を抽 出します。 複数の最大値に割り当てられた領域は、分割されません。

アルゴリズムが、画像の残りとは異なる均一な背景を分割することを避け るために、パラメーター MinGrayminGraymin_gray と MaxGraymaxGraymax_gray は、背 景とみなすべき画像内の領域に対するグレイ値しきい値を決定します。 MinGrayminGraymin_gray より小さいあるいは MaxGraymaxGraymax_gray より大きい値 をもつ画像のすべての部分は、最大部の抽出ならびに領域の割り当てに対し て無視されます。画像の完全な分割のためには、MinGrayminGraymin_gray = 0 と MaxGraymaxGraymax_gray = 255 が選ばれるべきです。MinGrayminGraymin_gray \(<\) MaxGraymaxGraymax_gray でなければなりません。

実行情報🔗

実行情報
  • マルチスレッドタイプ: 相互的(自分自身を除く他の非排他的オペレーターと並列に動作)

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

  • 並列演算処理には未対応

パラメーター🔗

Imageimageimage (input_object) singlechannelimage → object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

入力画像

Regionsregionsregions (output_object) region-array → objectHObjectHRegionHObjectHobject *

抽出された結果領域

Modemodemode (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

オペレーションモード

初期値: 'all'"all"
値のリスト: 'all', 'maxima', 'regions'"all", "maxima", "regions"

MinGrayminGraymin_gray (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

最小グレイしきい値

初期値: 00
推奨値: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110
値域: 0 ≤ MinGray ≤ 254 (lin)
最小増分: 1
推奨増分: 10

MaxGraymaxGraymax_gray (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

最大グレイしきい値

初期値: 255255
推奨値: 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 255100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 255
値域: 1 ≤ MaxGray ≤ 255 (lin)
最小増分: 1
推奨増分: 10
制限: MaxGray > MinGray

例🔗

(HDevelop)


* Segment a filtered image
read_image(Image,'particle')
mean_image(Image,Mean,11,11)
pouring(Mean,Seg,'all',0,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

* Segment an image while masking the dark background
read_image(Image,'particle')
mean_image(Image,ImageMean,15,15)
pouring(Mean,Seg,'all',90,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)
(C)
/* Segmentation of a filtered image */
read_image(&Image,"br2")\;
mean_image(Image,&Mean,11,11)\;
pouring(Mean,&Seg,"all",0,255)\;
disp_image(Mean,WindowHandle)\;
set_colored(WindowHandle,12)\;
disp_region(Seg,WindowHandle)\;

/* Segmentation of an image with masking of a dark backround */
read_image(&Image,"hand")\;
mean_image(Image,&Mean,15,15)\;
pouring(Mean,&Seg,"all",40,255)\;
disp_image(Mean,WindowHandle)\;
set_colored(WindowHandle,12)\;
disp_region(Seg,WindowHandle)\;
(C++)
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#include "HalconCpp.h"
using namespace Halcon\;

int main (int argc, char *argv[])
{
  HImage   img1 ("br2"),
           img2 ("hand"),
           img3 ("monkey"),
           texture,
           testreg\;
 HWindow      w1, w2, w3\;
  HRegion      region\;
  HRegionArray seg\;
 w1.SetColored (12)\;   img1.Display (w1)\;
  w2.SetColored (12)\;   img2.Display (w2)\;
  w3.SetColored (12)\;   img3.Display (w3)\;
 cout << "Smoothing of images 1 and 2 ..." << endl\;
 HImage mean1 = img1.MeanImage (11, 11)\;
  HImage mean2 = img2.MeanImage (15, 15)\;
 cout << "Full segmentation of images ... " << endl\;
  seg = mean1.Pouring ("all", 0, 255)\;
  seg.Display (w1)\;
 cout << "Segmentation with: a) masked background " << endl\;
  cout << "                   b) intersection " << endl\;
  seg = mean2.Pouring ("regions", 40, 255)\;
  seg.Display (w2)\;
 cout << "Segmentation in 2d-histogram" << endl\;
  cout << "Draw region with the mouse: " << endl\;
 region  = w3.DrawRegion ()\;
  texture = img3.TextureLaws ("el", 2, 5)\;
 testreg = texture.ReduceDomain (region)\;
  histo   = testreg.Histo2dim (texture, region)\;
  seg     = histo.Pouring ("all", 0, 255)\;
 seg.Display (w3)\;
  w3.Click ()\;
  return (0)\;
}

複雑性🔗

入力画像内のピクセル数を \(N\) とし、見つけられたセグメント数を \(M\) とします。ここで、セグメント \(i\) の囲む矩形は \(m_{i}\) ピクセルを含みます。さらに \(K_{i}\) をセグメント \(i\) 内の コード数とします。その場合、実行時間は以下のようになります。

\[\begin{eqnarray*} O( 3*N + sum_{M} (3*m_{i}) + sum_{M} (K_{i}) ) \enspace .\end{eqnarray*}\]

結果🔗

pouringPouring は、通常、値 2 (H_MSG_TRUE) を返します。必要に応じて、例外が 発生します。

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

組み合わせ

前処理の候補

binomial_filterBinomialFilter, gauss_filterGaussFilter, smooth_imageSmoothImage, mean_imageMeanImage

他の選択候補

watershedsWatersheds, local_maxLocalMax, watersheds_thresholdWatershedsThreshold, watersheds_markerWatershedsMarker

関連項目

histo_2dimHisto2dim, expand_regionExpandRegion, expand_grayExpandGray, expand_gray_refExpandGrayRef

モジュール🔗

Foundation