濃度投影結果クラス
Namespace: FVIL.MeasureAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
[SerializableAttribute] public class CFviProjectionResult : CFviDataObject, IEnumerable<Statistics>, IXmlSerializable |
Visual Basic |
---|
<SerializableAttribute> Public Class CFviProjectionResult Inherits CFviDataObject Implements IEnumerable(Of Statistics), IXmlSerializable |
Remarks
濃度投影クラス(CFviProjection)の計測結果を格納するクラスです。
Examples
下図の画像の Y 方向の濃度投影を取得する処理です。
【処理対象】
計測結果
16x12 pixel の画像の Y 方向の濃度投影を取得した結果です。
配列の要素数は 16 です。各要素の統計データ数(Count)は 12 です。
計測方向の取得
計測実行後、このクラスの Direction プロパティに計測方向が設定されます。
計測範囲の取得
計測実行後、このクラスの Window プロパティに計測範囲が設定されます。
下記は、左から St.X, St.Y, Ed.X, Ed.Y, Angle, Center.X, Center.Y の順に出力しています。
終点(Ed)を範囲に含む仕様です。例えば幅を求める場合は Ed.X - St.X + 1 と計算する必要があります。
回転中心(Center)は、始点(St)からの相対値を示します。
指定フィールドのデータ配列の取得
GetItems(String) メソッドを使用すると任意のフィールドを1次元配列に抽出できます。
配列の要素数は、このクラスが保有する要素数(Count)と同一です。
指定フィールドの統計データの取得
GetStatistics(String) メソッドを使用すると任意のフィールドの統計データを算出できます。
統計データ数(Count)は、このクラスが保有する要素数(Count)と同一です。
ソースコード:
【処理対象】
※この画像は視覚的な確認の為、グリッド線を描画しています。
計測結果
16x12 pixel の画像の Y 方向の濃度投影を取得した結果です。
配列の要素数は 16 です。各要素の統計データ数(Count)は 12 です。
No. ,Count, Sum, Mean, Min, Max, Sigma, Var [000] 12, 84, 7.000, 0.000, 26.000, 8.307, 69.000 [001] 12, 101, 8.417, 0.000, 29.000, 8.864, 78.576 [002] 12, 125, 10.417, 0.000, 30.000, 9.639, 92.910 [003] 12, 64, 5.333, 0.000, 31.000, 8.844, 78.222 [004] 12, 70, 5.833, 0.000, 17.000, 5.444, 29.639 [005] 12, 80, 6.667, 0.000, 15.000, 5.452, 29.722 [006] 12, 103, 8.583, 0.000, 43.000, 12.440, 154.743 [007] 12, 339, 28.250, 0.000, 76.000, 30.186, 911.188 [008] 12, 287, 23.917, 0.000, 86.000, 32.304, 1043.576 [009] 12, 344, 28.667, 0.000, 87.000, 29.990, 899.389 [010] 12, 56, 4.667, 0.000, 13.000, 4.365, 19.056 [011] 12, 78, 6.500, 0.000, 25.000, 8.170, 66.750 [012] 12, 89, 7.417, 0.000, 21.000, 7.488, 56.076 [013] 12, 108, 9.000, 0.000, 30.000, 9.046, 81.833 [014] 12, 161, 13.417, 4.000, 25.000, 6.576, 43.243 [015] 12, 54, 4.500, 0.000, 22.000, 7.171, 51.417
計測方向の取得
計測実行後、このクラスの Direction プロパティに計測方向が設定されます。
Direction: FVIL.Measure.Direction.Y
計測範囲の取得
計測実行後、このクラスの Window プロパティに計測範囲が設定されます。
下記は、左から St.X, St.Y, Ed.X, Ed.Y, Angle, Center.X, Center.Y の順に出力しています。
終点(Ed)を範囲に含む仕様です。例えば幅を求める場合は Ed.X - St.X + 1 と計算する必要があります。
回転中心(Center)は、始点(St)からの相対値を示します。
Window : 0.000, 0.000, 15.000, 11.000, 0.000, 0.000, 0.000
指定フィールドのデータ配列の取得
GetItems(String) メソッドを使用すると任意のフィールドを1次元配列に抽出できます。
配列の要素数は、このクラスが保有する要素数(Count)と同一です。
Name , [000], [001], [002], [003], [004], [005], [006], [007], [008], [009], [010], [011], [012], [013], [014], [015], Count : 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, Sum : 84.0, 101.0, 125.0, 64.0, 70.0, 80.0, 103.0, 339.0, 287.0, 344.0, 56.0, 78.0, 89.0, 108.0, 161.0, 54.0, Mean : 7.0, 8.4, 10.4, 5.3, 5.8, 6.7, 8.6, 28.3, 23.9, 28.7, 4.7, 6.5, 7.4, 9.0, 13.4, 4.5, Min : 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, Max : 26.0, 29.0, 30.0, 31.0, 17.0, 15.0, 43.0, 76.0, 86.0, 87.0, 13.0, 25.0, 21.0, 30.0, 25.0, 22.0, Sigma : 8.3, 8.9, 9.6, 8.8, 5.4, 5.5, 12.4, 30.2, 32.3, 30.0, 4.4, 8.2, 7.5, 9.0, 6.6, 7.2, Variance : 69.0, 78.6, 92.9, 78.2, 29.6, 29.7, 154.7, 911.2,1043.6, 899.4, 19.1, 66.8, 56.1, 81.8, 43.2, 51.4,
指定フィールドの統計データの取得
GetStatistics(String) メソッドを使用すると任意のフィールドの統計データを算出できます。
統計データ数(Count)は、このクラスが保有する要素数(Count)と同一です。
Name ,Count, Sum, Mean, Min, Max, Sigma, Var Count : 16, 192, 12.000, 12.000, 12.000, 0.000, 0.000 Sum : 16, 2143, 133.938, 54.000, 344.000, 95.239, 9070.434 Mean : 16, 179, 11.161, 4.500, 28.667, 7.937, 62.989 Min : 16, 4, 0.250, 0.000, 4.000, 0.968, 0.938 Max : 16, 576, 36.000, 13.000, 87.000, 23.704, 561.875 Sigma : 16, 194, 12.143, 4.365, 32.304, 9.172, 84.134 Variance : 16, 3705, 231.584, 19.056, 1043.576, 348.271, 121292.818
ソースコード:
C# | Copy |
---|---|
using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace User.SampleCode { public partial class Measure { /// <summary> /// 濃度投影 /// </summary> [FvPluginExecute] public void ProjectionResult() { FVIL.Data.CFviImage src = new FVIL.Data.CFviImage(Defs.TestImageDir + "/Projection_Noise.png"); FVIL.CFviTimeCounter watch = new FVIL.CFviTimeCounter(); double msec = 0; Dictionary<string, double> times = new Dictionary<string, double>(); #region 画像統計量. { FVIL.Measure.CFviProjectionResult result_y = new FVIL.Measure.CFviProjectionResult(); FVIL.Measure.CFviProjection parser = new FVIL.Measure.CFviProjection(src, 0, FVIL.Measure.Direction.Y, result_y); // X 方向. watch.Start(); parser.Execute(); msec = watch.Stop(); times["FVIL.Measure.CFviProjection.Execute"] = msec; // 出力. Console.WriteLine( "{0,-5},{1,5},{2,9},{3,9},{4,9},{5,9},{6,9},{7,9}", "No.", "Count", "Sum", "Mean", "Min", "Max", "Sigma", "Var"); for (int i = 0; i < result_y.Count; i++) { FVIL.Statistics stat = result_y[i]; Console.WriteLine( "[{0:000}] {1,5:0},{2,9:0},{3,9:0.000},{4,9:0.000},{5,9:0.000},{6,9:0.000},{7,9:0.000}", i, stat.Count, stat.Sum, stat.Mean, stat.Min, stat.Max, stat.Sigma, stat.Variance); } // 計測方向の取得. Console.WriteLine("{0,-9}: {1}.{2}", "Direction", result_y.Direction.GetType().FullName, result_y.Direction); // 計測範囲の取得. Console.WriteLine( "{0,-9}: {1,9:0.000},{2,9:0.000},{3,9:0.000},{4,9:0.000},{5,9:0.000},{6,9:0.000},{7,9:0.000}", "Window", result_y.Window.St.X, result_y.Window.St.Y, result_y.Window.Ed.X, result_y.Window.Ed.Y, result_y.Window.Angle.Degree, result_y.Window.Center.X, result_y.Window.Center.Y ); // 指定フィールドの抽出. string[] names = { "Count", "Sum", "Mean", "Min", "Max", "Sigma", "Variance" }; // 指定フィールドのデータ配列の取得. msec = 0; { Console.Write("{0,-9},", "Name"); for (int i = 0; i < result_y.Count; i++) { Console.Write(" [{0:000}],", i); } Console.WriteLine(""); } foreach (string name in names) { watch.Start(); FVIL.DOUBLE_ARRAY datas = result_y.GetItems(name); msec += watch.Stop(); // 出力. Console.Write("{0,-9}:", name); for (int i = 0; i < datas.Count; i++) { Console.Write("{0,6:0.0},", datas[i]); } Console.WriteLine(""); } times["FVIL.Measure.CFviProjection.GetItems"] = msec; // 指定フィールドの統計データの取得. msec = 0; { Console.WriteLine( "{0,-9},{1,5},{2,9},{3,9},{4,9},{5,9},{6,9},{7,11}", "Name", "Count", "Sum", "Mean", "Min", "Max", "Sigma", "Var"); } foreach (string name in names) { watch.Start(); FVIL.Statistics stat = result_y.GetStatistics(name); msec += watch.Stop(); Console.WriteLine( "{0,-9}:{1,5:0},{2,9:0},{3,9:0.000},{4,9:0.000},{5,9:0.000},{6,9:0.000},{7,11:0.000}", name, stat.Count, stat.Sum, stat.Mean, stat.Min, stat.Max, stat.Sigma, stat.Variance); } times["FVIL.Measure.CFviProjection.GetStatistics"] = msec; } #endregion Console.WriteLine(""); foreach (KeyValuePair<string, double> item in times) { Console.WriteLine("{0,9:0.000} msec : {1}", item.Value, item.Key); } } } } |
Visual Basic | Copy |
---|---|
Imports System Imports System.Collections.Generic Imports System.Text Imports fvalgcli Namespace SampleCode Partial Public Class Measure ''' <summary> ''' 濃度投影 ''' </summary> <FvPluginExecute()> _ Public Sub ProjectionResult() Dim src As New FVIL.Data.CFviImage(Defs.TestImageDir + "/Projection_Noise.png") Dim watch As New FVIL.CFviTimeCounter() Dim msec As Double = 0 Dim times As New Dictionary(Of String, Double)() '#Region "画像統計量." If True Then Dim result_y As New FVIL.Measure.CFviProjectionResult() Dim parser As New FVIL.Measure.CFviProjection(src, 0, FVIL.Measure.Direction.Y, result_y) ' X 方向. watch.Start() parser.Execute() msec = watch.[Stop]() times("FVIL.Measure.CFviProjection.Execute") = msec ' 出力. Console.WriteLine( _ "{0,-5},{1,5},{2,9},{3,9},{4,9},{5,9},{6,9},{7,9}", _ "No.", "Count", "Sum", "Mean", "Min", "Max", "Sigma", "Var") For i As Integer = 0 To result_y.Count - 1 Dim stat As FVIL.Statistics = result_y(i) Console.WriteLine( _ "[{0:000}] {1,5:0},{2,9:0},{3,9:0.000},{4,9:0.000},{5,9:0.000},{6,9:0.000},{7,9:0.000}", _ i, stat.Count, stat.Sum, stat.Mean, stat.Min, stat.Max, stat.Sigma, stat.Variance) Next ' 計測方向の取得. Console.WriteLine("{0,-9}: {1}.{2}", "Direction", _ result_y.Direction.[GetType]().FullName, result_y.Direction) ' 計測範囲の取得. Console.WriteLine( _ "{0,-9}: {1,9:0.000},{2,9:0.000},{3,9:0.000},{4,9:0.000},{5,9:0.000},{6,9:0.000},{7,9:0.000}", _ "Window", _ result_y.Window.St.X, result_y.Window.St.Y, _ result_y.Window.Ed.X, result_y.Window.Ed.Y, _ result_y.Window.Angle.Degree, _ result_y.Window.Center.X, result_y.Window.Center.Y) ' 指定フィールドの抽出. Dim names As String() = {"Count", "Sum", "Mean", "Min", "Max", "Sigma", "Variance"} ' 指定フィールドのデータ配列の取得. msec = 0 If True Then Console.Write("{0,-9},", "Name") For i As Integer = 0 To result_y.Count - 1 Console.Write(" [{0:000}],", i) Next Console.WriteLine("") End If For Each name As String In names watch.Start() Dim datas As FVIL.DOUBLE_ARRAY = result_y.GetItems(name) msec += watch.[Stop]() ' 出力. Console.Write("{0,-9}:", name) For i As Integer = 0 To datas.Count - 1 Console.Write("{0,6:0.0},", datas(i)) Next Console.WriteLine("") Next times("FVIL.Measure.CFviProjection.GetItems") = msec ' 指定フィールドの統計データの取得. msec = 0 If True Then Console.WriteLine( _ "{0,-9},{1,5},{2,9},{3,9},{4,9},{5,9},{6,9},{7,11}", _ "Name", "Count", "Sum", "Mean", "Min", "Max", "Sigma", "Var") End If For Each name As String In names watch.Start() Dim stat As FVIL.Statistics = result_y.GetStatistics(name) msec += watch.[Stop]() Console.WriteLine( _ "{0,-9}:{1,5:0},{2,9:0},{3,9:0.000},{4,9:0.000},{5,9:0.000},{6,9:0.000},{7,11:0.000}", _ name, stat.Count, stat.Sum, stat.Mean, stat.Min, stat.Max, stat.Sigma, stat.Variance) Next times("FVIL.Measure.CFviProjection.GetStatistics") = msec End If '#End Region Console.WriteLine("") For Each item As KeyValuePair(Of String, Double) In times Console.WriteLine("{0,9:0.000} msec : {1}", item.Value, item.Key) Next End Sub End Class End Namespace |
Inheritance Hierarchy
System..::..Object
FVIL..::..CFviObject
FVIL.Data..::..CFviDataObject
FVIL.Measure..::..CFviProjectionResult
FVIL..::..CFviObject
FVIL.Data..::..CFviDataObject
FVIL.Measure..::..CFviProjectionResult