同時生起行列を用いた局所一様性の算出

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

Syntax

C#
public static int fnFIE_texture_calc_gcm_local_homogeneity(
	FMATRIX_PTR mat,
	ref double lh
)
Visual Basic
Public Shared Function fnFIE_texture_calc_gcm_local_homogeneity ( 
	mat As FMATRIX_PTR,
	ByRef lh As Double
) As Integer

Parameters

mat
Type: fvalgcli..::..FMATRIX_PTR
同時生起行列
  • mat->row == mat->col
  • 0 < mat->row < 16384 かつ 0 < mat->col < 16384
  • mat->row を入力画像の階調数とする
lh
Type: System..::..Double%
局所一様性

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAM不正なパラメータが渡された
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
    {
        /// <summary>
        /// 同時生起行列を用いた局所一様性の算出
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_texture_calc_gcm_local_homogeneity()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE img = FHANDLE.Zero;
            FMATRIX_PTR mat = FMATRIX_PTR.Zero;    // 同時生起行列
            double lh = new double();    // 局所一様性

            try
            {
                // テストケース
                const int gray_level = 9;
                const int dx = 1;
                const int dy = 0;
                const int width = 4;
                const int height = 4;
                byte[,] img_data = new byte[width, height]{
                {0, 1, 2, 0},
                {3, 4, 5, 6},
                {6, 7, 8, 6},
                {1, 1, 3, 3}
            };
                const double ans_lh = 0.50833333333333;

                // 同時生起行列算出用の画像を用意する.
                img = api.fnFIE_img_root_alloc((int)f_imgtype.F_IMG_UC8, 1, width, height);

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        api.fnFIE_img_set_dens(img, 0, x, y, img_data[y, x]);
                    }
                }

                // 同時生起行列を確保、算出する.
                mat = api.fnFIE_mat_aalloc(gray_level, gray_level);
                api.fnFIE_texture_coocurrence_matrix(img, dx, dy, gray_level, mat);

                // 不要になった画像を開放する.
                api.fnFIE_free_object(img); img = FHANDLE.Zero;

                // 同時生起行列を用いた局所一様性の算出.
                status = api.fnFIE_texture_calc_gcm_local_homogeneity(mat, ref lh);

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

                // 結果を出力する.
                ConsoleOut.WriteFunctionName(":\t");
                Console.Write("lh = {0:f5} ...", lh);
                ConsoleOut.IsTrue(DblEqual(lh, ans_lh));
            }
            finally
            {
                mat.Dispose();
                img.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_texture_calc_gcm_local_homogeneity()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim img As FHANDLE = FHANDLE.Zero
        Dim mat As FMATRIX_PTR = FMATRIX_PTR.Zero
        ' 同時生起行列
        Dim lh As New Double()
        ' 局所一様性
        Try
            ' テストケース
            Const  gray_level As Integer = 9
            Const  dx As Integer = 1
            Const  dy As Integer = 0
            Const  width As Integer = 4
            Const  height As Integer = 4
            Dim img_data As Byte(,) = New Byte(width - 1, height - 1) {{0, 1, 2, 0}, {3, 4, 5, 6}, {6, 7, 8, 6}, {1, 1, 3, 3}}
            Const  ans_lh As Double = 0.50833333333333

            ' 同時生起行列算出用の画像を用意する.
            img = api.fnFIE_img_root_alloc(CInt(f_imgtype.F_IMG_UC8), 1, width, height)

            For y As Integer = 0 To height - 1
                For x As Integer = 0 To width - 1
                    api.fnFIE_img_set_dens(img, 0, x, y, img_data(y, x))
                Next
            Next

            ' 同時生起行列を確保、算出する.
            mat = api.fnFIE_mat_aalloc(gray_level, gray_level)
            api.fnFIE_texture_coocurrence_matrix(img, dx, dy, gray_level, mat)

            ' 不要になった画像を開放する.
            api.fnFIE_free_object(img)
            img = FHANDLE.Zero

            ' 同時生起行列を用いた局所一様性の算出.
            status = api.fnFIE_texture_calc_gcm_local_homogeneity(mat, lh)

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

            ' 結果を出力する.
            ConsoleOut.WriteFunctionName(":" & vbTab)
            Console.Write("lh = {0:f5} ...", lh)
            ConsoleOut.IsTrue(DblEqual(lh, ans_lh))
        Finally
            mat.Dispose()
            img.Dispose()
        End Try
    End Sub
End Class

See Also