同時生起行列を用いたエネルギーの算出
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_texture_calc_gcm_energy( FMATRIX_PTR mat, ref double energy ) |
Visual Basic |
---|
Public Shared Function fnFIE_texture_calc_gcm_energy ( mat As FMATRIX_PTR, ByRef energy As Double ) As Integer |
Parameters
- mat
- Type: fvalgcli..::..FMATRIX_PTR
同時生起行列- mat->row == mat->col
- 0 < mat->row < 16384 かつ 0 < mat->col < 16384
- mat->row を入力画像の階調数とする
- energy
- Type: System..::..Double%
エネルギー
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_PARAM | 不正なパラメータが渡された |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Remarks
Examples
C# | Copy |
---|---|
// $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_energy() { int status = (int)f_err.F_ERR_NONE; FHANDLE img = FHANDLE.Zero; // 同時生起行列算出用の画像. FMATRIX_PTR mat = FMATRIX_PTR.Zero; // 同時生起行列. 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_energy = 0.048611111111111; // 同時生起行列算出用の画像を用意する. 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); // 同時生起行列を用いたエネルギーの算出. double energy = 0; status = api.fnFIE_texture_calc_gcm_energy(mat, ref energy); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 結果を出力する. ConsoleOut.WriteFunctionName(":\t"); Console.Write("energy = {0:f5} ...", energy); ConsoleOut.IsTrue(DblEqual(energy, ans_energy)); } finally { img.Dispose(); mat.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $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_energy() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim img As FHANDLE = FHANDLE.Zero ' 同時生起行列算出用の画像. Dim mat As FMATRIX_PTR = FMATRIX_PTR.Zero ' 同時生起行列. 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_energy As Double = 0.048611111111111 ' 同時生起行列算出用の画像を用意する. 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) ' 同時生起行列を用いたエネルギーの算出. Dim energy As Double = 0 status = api.fnFIE_texture_calc_gcm_energy(mat, energy) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 結果を出力する. ConsoleOut.WriteFunctionName(":" & vbTab) Console.Write("energy = {0:f5} ...", energy) ConsoleOut.IsTrue(DblEqual(energy, ans_energy)) Finally img.Dispose() mat.Dispose() End Try End Sub End Class |