構造要素指定 unconstrained thinning
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_thinning( FHANDLE hsrc_img, FHANDLE hdst_img, FHANDLE hse_FG, FHANDLE hse_BG ) |
Visual Basic |
---|
Public Shared Function fnFIE_thinning ( hsrc_img As FHANDLE, hdst_img As FHANDLE, hse_FG As FHANDLE, hse_BG As FHANDLE ) As Integer |
Parameters
- hsrc_img
- Type: fvalgcli..::..FHANDLE
処理対象画像( type: bin, uc8, s16, us16, double )
- hdst_img
- Type: fvalgcli..::..FHANDLE
処理結果画像( type: bin, uc8, s16, us16, double )
- hse_FG
- Type: fvalgcli..::..FHANDLE
値が1の画素に対応する構造要素のハンドル
- hse_BG
- Type: fvalgcli..::..FHANDLE
値が0の画素に対応する構造要素のハンドル
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_IMAGE | 不正な画像ハンドルが渡されたため、異常終了 |
F_ERR_INVALID_OBJECT | 構造要素に不正なハンドルが指定されたため異常終了 |
F_ERR_NOMEMORY | メモリ不足で確保に失敗した |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Examples
C# | Copy |
---|---|
// $Revision: 1.1 $ using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace TC { public partial class FIE { /// <summary> /// 構造要素指定 unconstrained thinning. /// </summary> [FvPluginExecute] public void fnFIE_thinning() { int status = (int)f_err.F_ERR_NONE; FHANDLE hsrc1 = FHANDLE.Zero; // 処理対象画像. FHANDLE hdst = FHANDLE.Zero; // 処理結果画像. FHANDLE hFG = FHANDLE.Zero; FHANDLE hBG = FHANDLE.Zero; UCHAR_PTR ptrn = UCHAR_PTR.Zero; UCHAR_PTR ptrn2 = UCHAR_PTR.Zero; try { // ptrn = { // 0,0,0, // 0,1,0, // 0,0,0 // }; ptrn = UCHAR_PTR.alloc(9); for (int i = 0; i < 9; i++) { if (i == 4) ptrn[i] = 1; else ptrn[i] = 0; } ptrn2 = UCHAR_PTR.alloc(9); for (int i = 0; i < 9; i++) { if (ptrn[i] == 1) ptrn2[i] = 0; else ptrn2[i] = 1; } // 入力画像ファイルのロード. api.fnFIE_load_img_file(TestImageDir + "/testdata/gray_04.bmp", ref hsrc1, f_color_img_type.F_COLOR_IMG_TYPE_UC8); // 入力画像の情報取得. int width = api.fnFIE_img_get_width(hsrc1); int height = api.fnFIE_img_get_height(hsrc1); int channels = api.fnFIE_img_get_channels(hsrc1); int type = api.fnFIE_img_get_type(hsrc1); // 出力画像の生成. hdst = api.fnFIE_img_root_alloc(type, channels, width, height); // 構造要素の生成 hFG = api.fnFIE_morphology_se_alloc(ptrn, 3, 3, 3, 1, 1); hBG = api.fnFIE_morphology_se_alloc(ptrn2, 3, 3, 3, 1, 1); // 処理の実行. status = api.fnFIE_thinning(hsrc1, hdst, hFG, hBG); // エラー判定. Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 出力画像の保存. api.fnFIE_save_png(ResultDir + "/fnFIE_thinning.png", hdst, -1); } finally { // オブジェクトの開放. hsrc1.Dispose(); hdst.Dispose(); hFG.Dispose(); hBG.Dispose(); ptrn.Dispose(); ptrn2.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE ''' <summary> ''' 構造要素指定 unconstrained thinning. ''' </summary> <FvPluginExecute> _ Public Sub fnFIE_thinning() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim hsrc1 As FHANDLE = FHANDLE.Zero ' 処理対象画像. Dim hdst As FHANDLE = FHANDLE.Zero ' 処理結果画像. Dim hFG As FHANDLE = FHANDLE.Zero Dim hBG As FHANDLE = FHANDLE.Zero Dim ptrn As UCHAR_PTR = UCHAR_PTR.Zero Dim ptrn2 As UCHAR_PTR = UCHAR_PTR.Zero Try ' ptrn = { ' 0,0,0, ' 0,1,0, ' 0,0,0 ' }; ptrn = UCHAR_PTR.alloc(9) For i As Integer = 0 To 8 If i = 4 Then ptrn(i) = 1 Else ptrn(i) = 0 End If Next ptrn2 = UCHAR_PTR.alloc(9) For i As Integer = 0 To 8 If ptrn(i) = 1 Then ptrn2(i) = 0 Else ptrn2(i) = 1 End If Next ' 入力画像ファイルのロード. api.fnFIE_load_img_file(TestImageDir & "/testdata/gray_04.bmp", hsrc1, f_color_img_type.F_COLOR_IMG_TYPE_UC8) ' 入力画像の情報取得. Dim width As Integer = api.fnFIE_img_get_width(hsrc1) Dim height As Integer = api.fnFIE_img_get_height(hsrc1) Dim channels As Integer = api.fnFIE_img_get_channels(hsrc1) Dim type As Integer = api.fnFIE_img_get_type(hsrc1) ' 出力画像の生成. hdst = api.fnFIE_img_root_alloc(type, channels, width, height) ' 構造要素の生成 hFG = api.fnFIE_morphology_se_alloc(ptrn, 3, 3, 3, 1, 1) hBG = api.fnFIE_morphology_se_alloc(ptrn2, 3, 3, 3, 1, 1) ' 処理の実行. status = api.fnFIE_thinning(hsrc1, hdst, hFG, hBG) ' エラー判定. Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 出力画像の保存. api.fnFIE_save_png(ResultDir & "/fnFIE_thinning.png", hdst, -1) Finally ' オブジェクトの開放. hsrc1.Dispose() hdst.Dispose() hFG.Dispose() hBG.Dispose() ptrn.Dispose() ptrn2.Dispose() End Try End Sub End Class |