濃淡ヒストグラムの算出
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_texture_first_order_statistics( FHANDLE hsrc, ref double ave, ref double sgm2, ref double skewness, ref double kurtosis ) |
Visual Basic |
---|
Public Shared Function fnFIE_texture_first_order_statistics ( hsrc As FHANDLE, ByRef ave As Double, ByRef sgm2 As Double, ByRef skewness As Double, ByRef kurtosis As Double ) As Integer |
Parameters
- hsrc
- Type: fvalgcli..::..FHANDLE
入力画像( type: uc8, us16 / ch : 1 )
- ave
- Type: System..::..Double%
平均値(μ)
- sgm2
- Type: System..::..Double%
分散の2乗(σ^2)
- skewness
- Type: System..::..Double%
歪度(Skewness)
- kurtosis
- Type: System..::..Double%
尖度(Kurtosis)
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_IMAGE | 不正な画像オブジェクトが渡された |
F_ERR_INVALID_PARAM | 不正なパラメータが渡された
|
F_ERR_NOMEMORY | メモリ不足 |
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_first_order_statistics() { int status = (int)f_err.F_ERR_NONE; FHANDLE hsrc = FHANDLE.Zero; // 入力画像. try { double ave = new double(); // 平均値(μ) double sgm2 = new double(); // 分散の2乗(σ^2) double skewness = new double(); // 歪度(Skewness) double kurtosis = new double(); // 尖度(Kurtosis) // テストケース. byte[,] img_data = new byte[,]{ {4, 5, 6}, {7, 8, 6}, {1, 3, 3} }; int img_width = img_data.GetLength(1); int img_height = img_data.GetLength(0); const double ans_ave = 4.77777777777777777777777777777; const double ans_sgm2 = 4.3950617283931; const double ans_skewness = -0.21140407157430; const double ans_kurtosis = 2.0746433531120; // 入力画像を用意する. hsrc = api.fnFIE_img_root_alloc((int)f_imgtype.F_IMG_UC8, 1, img_width, img_height); for (int y = 0; y < img_height; y++) { for (int x = 0; x < img_width; x++) { api.fnFIE_img_set_dens(hsrc, 0, x, y, img_data[y, x]); } } // 濃淡ヒストグラムの算出. status = api.fnFIE_texture_first_order_statistics(hsrc, ref ave, ref sgm2, ref skewness, ref kurtosis); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 結果を出力する. ConsoleOut.WriteFunctionName(":\n"); Console.Write("\tave={0:f3}, sgm2={1:f3}, skewness={2:f3}, kurtosis={3:f3} ...", ave, sgm2, skewness, kurtosis); ConsoleOut.IsTrue( DblEqual(ave, ans_ave) && DblEqual(sgm2, ans_sgm2) && DblEqual(skewness, ans_skewness) && DblEqual(kurtosis, ans_kurtosis) ); } finally { // 入力画像を解放する. hsrc.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_first_order_statistics() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim hsrc As FHANDLE = FHANDLE.Zero ' 入力画像. Try Dim ave As New Double() ' 平均値(μ) Dim sgm2 As New Double() ' 分散の2乗(σ^2) Dim skewness As New Double() ' 歪度(Skewness) Dim kurtosis As New Double() ' 尖度(Kurtosis) ' テストケース. Dim img_data As Byte(,) = New Byte(,) {{4, 5, 6}, {7, 8, 6}, {1, 3, 3}} Dim img_width As Integer = img_data.GetLength(1) Dim img_height As Integer = img_data.GetLength(0) Const ans_ave As Double = 4.77777777777778 Const ans_sgm2 As Double = 4.3950617283931 Const ans_skewness As Double = -0.2114040715743 Const ans_kurtosis As Double = 2.074643353112 ' 入力画像を用意する. hsrc = api.fnFIE_img_root_alloc(CInt(f_imgtype.F_IMG_UC8), 1, img_width, img_height) For y As Integer = 0 To img_height - 1 For x As Integer = 0 To img_width - 1 api.fnFIE_img_set_dens(hsrc, 0, x, y, img_data(y, x)) Next Next ' 濃淡ヒストグラムの算出. status = api.fnFIE_texture_first_order_statistics(hsrc, ave, sgm2, skewness, kurtosis) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 結果を出力する. ConsoleOut.WriteFunctionName(":" & vbLf) Console.Write(vbTab & "ave={0:f3}, sgm2={1:f3}, skewness={2:f3}, kurtosis={3:f3} ...", ave, sgm2, skewness, kurtosis) ConsoleOut.IsTrue(DblEqual(ave, ans_ave) AndAlso DblEqual(sgm2, ans_sgm2) AndAlso DblEqual(skewness, ans_skewness) AndAlso DblEqual(kurtosis, ans_kurtosis)) Finally ' 入力画像を解放する. hsrc.Dispose() End Try End Sub End Class |