構造要素のアンカー位置変更

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static int fnFIE_morphology_set_anchor(
	FHANDLE hse,
	int anchor_x,
	int anchor_y
)
Visual Basic
Public Shared Function fnFIE_morphology_set_anchor ( 
	hse As FHANDLE,
	anchor_x As Integer,
	anchor_y As Integer
) As Integer

Parameters

hse
Type: fvalgcli..::..FHANDLE
構造要素のハンドル
anchor_x
Type: System..::..Int32
構造要素のX方向アンカー位置( 0 ≦ anchor_x < 構造要素のX方向サイズ )
anchor_y
Type: System..::..Int32
構造要素のY方向アンカー位置( 0 ≦ anchor_y <構造要素のY方向サイズ )

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_OBJECT 不正なハンドルが渡されたため異常終了
F_ERR_INVALID_PARAMパラメータ異常
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// 構造要素のアンカー位置変更.
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_morphology_set_anchor()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hse = FHANDLE.Zero;        // 構造要素.
            UCHAR_PTR ptrn = 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;
                }

                // 構造要素の生成
                hse = api.fnFIE_morphology_se_alloc(ptrn, 3, 3, 3, 1, 1);

                // 処理の実行.
                status = api.fnFIE_morphology_set_anchor(hse, 2, 2);

                // エラー判定.
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);

                // 処理結果確認.
                int size_x = 0;
                int size_y = 0;
                int anchor_x = 0;
                int anchor_y = 0;
                status = api.fnFIE_morphology_get_params(hse, ref size_x, ref size_y, ref anchor_x, ref anchor_y);
                Assert.IsTrue(anchor_x == 2 && anchor_y == 2, "期待値と一致しません.");
            }
            finally
            {
                // オブジェクトの開放.
                hse.Dispose();
                ptrn.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' 構造要素のアンカー位置変更.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_morphology_set_anchor()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hse As FHANDLE = FHANDLE.Zero
        ' 構造要素.
        Dim ptrn 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

            ' 構造要素の生成
            hse = api.fnFIE_morphology_se_alloc(ptrn, 3, 3, 3, 1, 1)

            ' 処理の実行.
            status = api.fnFIE_morphology_set_anchor(hse, 2, 2)

            ' エラー判定.
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))

            ' 処理結果確認.
            Dim size_x As Integer = 0
            Dim size_y As Integer = 0
            Dim anchor_x As Integer = 0
            Dim anchor_y As Integer = 0
            status = api.fnFIE_morphology_get_params(hse, size_x, size_y, anchor_x, anchor_y)
            Assert.IsTrue(anchor_x = 2 AndAlso anchor_y = 2, "期待値と一致しません.")
        Finally
            ' オブジェクトの開放.
            hse.Dispose()
            ptrn.Dispose()
        End Try
    End Sub
End Class

See Also