Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''<summary>Statistic information of one channel (RGB or total).</summary>
  2.        '''<remarks>The maximum word with is taken as pixel values to cover all fixed-point formats ...</remarks>
  3.        Public Structure sSingleChannelStatistics
  4.             '''<summary>Number of characters in the header of the report.</summary>
  5.            Public Shared ReadOnly Property ReportHeaderLength As Integer = 20
  6.             '''<summary>Number of characters in the value of the report.</summary>
  7.            Public Shared ReadOnly Property ReportValueLength As Integer = 16
  8.             '''<summary>Width [pixel] of the last image.</summary>
  9.            Public Width As UInt32
  10.             '''<summary>Height [pixel] of the last image.</summary>
  11.            Public Height As UInt32
  12.             '''<summary>Number of total samples (pixels) in the data set.</summary>
  13.            Public Samples As UInt64
  14.             '''<summary>Maximum value occured (value and number of pixel that have this value).</summary>
  15.            Public Max As KeyValuePair(Of Int64, UInt64)
  16.             '''<summary>Minimum value occured (value and number of pixel that have this value).</summary>
  17.            Public Min As KeyValuePair(Of Int64, UInt64)
  18.             '''<summary>Value where half of the samples are below and half are above.</summary>
  19.            Public Median As Int64
  20.             '''<summary>Arithmetic mean value.</summary>
  21.            Public Mean As Double
  22.             '''<summary>Mean value of squared values.</summary>
  23.            Public MeanPow2 As Double
  24.             '''<summary>Standard deviation (calculated as in FitsWork).</summary>
  25.            Public StdDev As Double
  26.             '''<summary>Number of different ADU values in the data.</summary>
  27.            Public DifferentADUValues As Integer
  28.             '''<summary>Number of different ADU values in 25-75 pct range.</summary>
  29.            Public ADUValues2575 As Integer
  30.             '''<summary>Distance between the histogram X axis points.</summary>
  31.            Public HistXDist As Dictionary(Of Long, UInt64)
  32.             '''<summary>Percentile.</summary>
  33.            Public Percentile As Dictionary(Of Integer, Int64)
  34.             '''<summary>Pixel value that is present the most often.</summary>
  35.            Public Modus As KeyValuePair(Of Int64, UInt64)
  36.             '''<summary>Standard deviation (calculated as in FitsWork).</summary>
  37.            Public ReadOnly Property Variance As Double
  38.                 Get
  39.                     Return StdDev ^ 2
  40.                 End Get
  41.             End Property
  42.             '''<summary>Init all inner variables.</summary>
  43.            Public Shared Function InitForShort() As sSingleChannelStatistics
  44.                 Dim RetVal As New sSingleChannelStatistics
  45.                 RetVal.Width = 0
  46.                 RetVal.Height = 0
  47.                 RetVal.Samples = 0
  48.                 RetVal.Max = Nothing
  49.                 RetVal.Min = Nothing
  50.                 RetVal.Mean = 0
  51.                 RetVal.MeanPow2 = 0
  52.                 RetVal.StdDev = Double.NaN
  53.                 RetVal.DifferentADUValues = 0
  54.                 RetVal.HistXDist = New Dictionary(Of Long, UInt64)
  55.                 RetVal.Median = Int64.MinValue
  56.                 RetVal.Percentile = New Dictionary(Of Integer, Int64)
  57.                 RetVal.Modus = Nothing
  58.                 Return RetVal
  59.             End Function
  60.             '''<summary>Report of all statistics properties of the structure.</summary>
  61.            '''<param name="DispHeader">TRUE to display the header, FALSE else.</param>
  62.            Public Function StatisticsReport() As List(Of String)
  63.                 Dim NotPresent As String = New String("-"c, ReportValueLength)
  64.                 Dim RetVal As New List(Of String)
  65.                 Dim HistXDist_keys As List(Of Long) = HistXDist.KeyList
  66.                 Dim TotalPixel As String = ((Samples / 1000000).ValRegIndep("0.0") & "M")
  67.                 If Samples < 1000000 Then TotalPixel = ((Samples / 1000).ValRegIndep("0.0") & "k")
  68.                 RetVal.Add("Dimensions        : " & (Width.ValRegIndep & "x" & Height.ValRegIndep).PadLeft(ReportValueLength))
  69.                 RetVal.Add("Total pixel       : " & Samples.ValRegIndep.PadLeft(ReportValueLength))
  70.                 RetVal.Add("Total pixel       : " & TotalPixel.PadLeft(ReportValueLength))
  71.                 RetVal.Add("ADU values count  : " & DifferentADUValues.ValRegIndep.PadLeft(ReportValueLength))
  72.                 RetVal.Add("  in 25-75 pct    : " & ADUValues2575.ValRegIndep.PadLeft(ReportValueLength))
  73.                 RetVal.Add("Min value         : " & (Min.Key.ValRegIndep & " (" & Min.Value.ValRegIndep & "x)").PadLeft(ReportValueLength))
  74.                 RetVal.Add("Modus value       : " & (Modus.Key.ValRegIndep & " (" & Modus.Value.ValRegIndep & "x)").PadLeft(ReportValueLength))
  75.                 RetVal.Add("Max value         : " & (Max.Key.ValRegIndep & " (" & Max.Value.ValRegIndep & "x)").PadLeft(ReportValueLength))
  76.                 RetVal.Add("Median value      : " & Median.ValRegIndep.PadLeft(ReportValueLength))
  77.                 RetVal.Add("Mean value        : " & Format(Mean, "0.000").ToString.Trim.PadLeft(ReportValueLength))
  78.                 RetVal.Add("Standard dev.     : " & Format(StdDev, "0.000").ToString.Trim.PadLeft(ReportValueLength))
  79.                 RetVal.Add("Variance          : " & Format(Variance, "0.000").ToString.Trim.PadLeft(ReportValueLength))
  80.                 'Data on histogram of ADU stepping
  81.                If HistXDist_keys.Count = 0 Then
  82.                     RetVal.Add("ADU step size min : " & NotPresent.PadLeft(ReportValueLength))
  83.                     RetVal.Add("ADU different step: " & NotPresent.PadLeft(ReportValueLength))
  84.                 Else
  85.                     RetVal.Add("ADU step size min : " & Format(HistXDist_keys(0), "####0").ToString.Trim.PadLeft(ReportValueLength))
  86.                     RetVal.Add("ADU different step: " & Format(HistXDist_keys.Count, "####0").ToString.Trim.PadLeft(ReportValueLength))
  87.                 End If
  88.                 'Percentile report
  89.                For Each Pct As Integer In New Integer() {1, 5, 10, 25, 50, 75, 90, 95, 99}
  90.                     If Percentile.ContainsKey(Pct) Then RetVal.Add(("Percentil - " & Pct.ToString.Trim.PadLeft(2) & " %  : ").PadRight(ReportHeaderLength) & Format(Percentile(Pct)).ToString.Trim.PadLeft(ReportValueLength))
  91.                 Next Pct
  92.                 Return RetVal
  93.             End Function
  94.         End Structure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement