REGION特徴量:指定角度フェレ径計測

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

Syntax

C#
public static int fnFIE_region_calc_feret_diameter(
	FHANDLE hreg,
	double theta,
	int mode,
	ref double diameter
)
Visual Basic
Public Shared Function fnFIE_region_calc_feret_diameter ( 
	hreg As FHANDLE,
	theta As Double,
	mode As Integer,
	ByRef diameter As Double
) As Integer

Parameters

hreg
Type: fvalgcli..::..FHANDLE
REGIONハンドル
theta
Type: System..::..Double
フェレ径を計測するときの角度(フェレ径計測軸とx軸がなす角度)単位:ラジアン
mode
Type: System..::..Int32
画素領域モード
  • 0 : 点で計測
  • 1 : 矩形の広がりを持つ点で計測
diameter
Type: System..::..Double%
フェレ径

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAM不正なパラメータが指定された
  • diameter に IntPtr.Zero が指定された
  • mode に 0 or 1 以外が指定された
F_ERR_INVALID_OBJECT不正なハンドル
F_ERR_CALC_IMPOSSIBLE 計算不能
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Remarks

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

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

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFIE_region_calc_feret_diameter()
        {
            FHANDLE himage = FHANDLE.Zero;
            FHANDLE hreg = FHANDLE.Zero;

            try
            {
                // 2値画像を読み込む.            
                api.fnFIE_load_img_file(TestImageDir + "/TC/SampleCode/blob_BIN.png", ref himage, f_color_img_type.F_COLOR_IMG_TYPE_UC8);
                Assert.IsTrue(himage != FHANDLE.Zero, "himage が異常です.");

                // 画像からリージョンを作成する.
                // --- オフセット.
                PNT_T offset = new PNT_T();
                offset.x = 0;
                offset.y = 0;
                // --- 作成.
                hreg = api.fnFIE_region_encode(himage, offset);

                // リージョン特徴量:指定角度フェレ径計測.
                double theta = 0;
                int mode = 1;
                double diameter = 0;
                int status = api.fnFIE_region_calc_feret_diameter(hreg, theta, mode, ref diameter);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "calc_feret_diameterでエラーが発生しました。({0})", (f_err)status);

                // 値の確認.
                Console.WriteLine("diameter={0}", diameter);
            }
            finally
            {
                himage.Dispose();
                hreg.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

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

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_region_calc_feret_diameter()
        Dim himage As FHANDLE = FHANDLE.Zero
        Dim hreg As FHANDLE = FHANDLE.Zero

        Try
            ' 2値画像を読み込む.            
            api.fnFIE_load_img_file(TestImageDir & "/TC/SampleCode/blob_BIN.png", himage, f_color_img_type.F_COLOR_IMG_TYPE_UC8)
            Assert.IsTrue(himage <> FHANDLE.Zero, "himage が異常です.")

            ' 画像からリージョンを作成する.
            ' --- オフセット.
            Dim offset As New PNT_T()
            offset.x = 0
            offset.y = 0
            ' --- 作成.
            hreg = api.fnFIE_region_encode(himage, offset)

            ' リージョン特徴量:指定角度フェレ径計測.
            Dim theta As Double = 0
            Dim mode As Integer = 1
            Dim diameter As Double = 0
            Dim status As Integer = api.fnFIE_region_calc_feret_diameter(hreg, theta, mode, diameter)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "calc_feret_diameterでエラーが発生しました。({0})", CType(status, f_err))

            ' 値の確認.
            Console.WriteLine("diameter={0}", diameter)
        Finally
            himage.Dispose()
            hreg.Dispose()
        End Try
    End Sub
End Class

See Also