同時生起行列の算出
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_texture_coocurrence_matrix( FHANDLE hsrc, int dx, int dy, int gray_level, FMATRIX_PTR mat ) |
Visual Basic |
---|
Public Shared Function fnFIE_texture_coocurrence_matrix ( hsrc As FHANDLE, dx As Integer, dy As Integer, gray_level As Integer, mat As FMATRIX_PTR ) As Integer |
Parameters
- hsrc
- Type: fvalgcli..::..FHANDLE
入力画像( type: uc8, us16 / ch : 1 )- 幅、および高さは2以上
- dx
- Type: System..::..Int32
水平方向パラメータ
- dy
- Type: System..::..Int32
垂直方向パラメータ
- gray_level
- Type: System..::..Int32
入力画像の階調数(1以上)
- mat
- Type: fvalgcli..::..FMATRIX_PTR
同時生起行列- mat->row == mat->col == gray_level
- 1 < mat->row < 16384 かつ 1 < mat->col < 16384
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_IMAGE | 不正な画像オが渡された |
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_coocurrence_matrix() { int status = (int)f_err.F_ERR_NONE; FHANDLE hsrc = FHANDLE.Zero; // 入力画像. const int dx = 1; // 水平方向パラメータ. const int dy = 0; // 垂直方向パラメータ. const int gray_level = 5; // 入力画像の階調数(1以上). FMATRIX_PTR mat = IntPtr.Zero; // 同時生起行列. const int width = 5; const int height = 5; try { // (入力画像 src に対して、gray_level=5, dx=1, dy=0 にて算出される同時生起行列は ans のようになる.) byte[,] src = new byte[width, height] { {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1} }; double[,] ans = new double[gray_level, gray_level] { {0, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; // 入力画像を用意する. hsrc = 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(hsrc, 0, x, y, src[y, x]); } } // 同時生起行列を確保する. mat = api.fnFIE_mat_aalloc(gray_level, gray_level); api.fnFIE_mat_zeros(mat); // 同時生起行列の算出. status = api.fnFIE_texture_coocurrence_matrix(hsrc, dx, dy, gray_level, mat); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 結果を出力する. ConsoleOut.WriteFunctionName(":\t"); { bool check = true; for (int y = 0; y < gray_level; y++) { for (int x = 0; x < gray_level; x++) { if (!DblEqual(mat[y, x], ans[y, x])) check = false; } } ConsoleOut.IsTrue(check); } ConsoleOut.WriteFMATRIX(mat, gray_level, gray_level); } finally { hsrc.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_coocurrence_matrix() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim hsrc As FHANDLE = FHANDLE.Zero ' 入力画像. Const dx As Integer = 1 ' 水平方向パラメータ. Const dy As Integer = 0 ' 垂直方向パラメータ. Const gray_level As Integer = 5 ' 入力画像の階調数(1以上). Dim mat As FMATRIX_PTR = IntPtr.Zero ' 同時生起行列. Const width As Integer = 5 Const height As Integer = 5 Try ' (入力画像 src に対して、gray_level=5, dx=1, dy=0 にて算出される同時生起行列は ans のようになる.) Dim src As Byte(,) = New Byte(width - 1, height - 1) {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} Dim ans As Double(,) = New Double(gray_level - 1, gray_level - 1) {{0, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}} ' 入力画像を用意する. hsrc = 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(hsrc, 0, x, y, src(y, x)) Next Next ' 同時生起行列を確保する. mat = api.fnFIE_mat_aalloc(gray_level, gray_level) api.fnFIE_mat_zeros(mat) ' 同時生起行列の算出. status = api.fnFIE_texture_coocurrence_matrix(hsrc, dx, dy, gray_level, mat) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 結果を出力する. ConsoleOut.WriteFunctionName(":" & vbTab) If True Then Dim check As Boolean = True For y As Integer = 0 To gray_level - 1 For x As Integer = 0 To gray_level - 1 If Not DblEqual(mat(y, x), ans(y, x)) Then check = False End If Next Next ConsoleOut.IsTrue(check) End If ConsoleOut.WriteFMATRIX(mat, gray_level, gray_level) Finally hsrc.Dispose() mat.Dispose() End Try End Sub End Class |