Skip to content

Commit

Permalink
add xml dev notes
Browse files Browse the repository at this point in the history
  • Loading branch information
xieguigang committed Jan 6, 2024
1 parent da63b96 commit a60d252
Showing 1 changed file with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#End Region

Imports System.Drawing
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.Imaging.Math2D
Imports std = System.Math

Expand Down Expand Up @@ -139,12 +140,13 @@ Namespace Drawing2D.HeatMap

Private Sub gaussiankernel()
Dim y = -r, i = 0
Dim sigma_2 As Double = gSigma ^ 2

While i < gSize
Dim x = -r, j = 0

While j < gSize
m_kernelField(i, j) = std.Exp((x * x + y * y) / (-2 * gSigma * gSigma)) / (2 * std.PI * gSigma * gSigma)
m_kernelField(i, j) = std.Exp((x * x + y * y) / (-2 * sigma_2)) / (2 * std.PI * sigma_2)
x += 1
j += 1
End While
Expand All @@ -156,14 +158,15 @@ Namespace Drawing2D.HeatMap

Private Function MultiplyKernel(weight As Double) As Double(,)
Dim wKernel As Double(,) = CType(m_kernelField.Clone(), Double(,))
For i = 0 To gSize - 1
For j = 0 To gSize - 1
For i As Integer = 0 To gSize - 1
For j As Integer = 0 To gSize - 1
wKernel(i, j) *= weight
Next
Next
Return wKernel
End Function

<MethodImpl(MethodImplOptions.AggressiveInlining)>
Public Function SetDatas(datas As IEnumerable(Of T)) As HeatMapRaster(Of T)
Return SetDataInternal(datas.ToArray)
End Function
Expand Down Expand Up @@ -221,6 +224,15 @@ Namespace Drawing2D.HeatMap
Return Me
End Function

''' <summary>
''' cast the sparse raster data as dense matrx liked raster data
''' </summary>
''' <param name="datas"></param>
''' <param name="w">the matrix width, ncols</param>
''' <param name="h">the matrix height, nrows</param>
''' <returns>the full scan <see cref="PixelData"/> spot data, number of
''' the returns collection equals to <paramref name="w"/> * <paramref name="h"/>.
''' </returns>
Public Shared Iterator Function PopulateDenseRasterMatrix(datas As IEnumerable(Of T), w As Integer, h As Integer) As IEnumerable(Of Pixel)
Dim matrix = datas _
.GroupBy(Function(a) a.X) _
Expand Down Expand Up @@ -254,6 +266,13 @@ Namespace Drawing2D.HeatMap
Next
End Function

''' <summary>
'''
''' </summary>
''' <param name="activator">
''' a delegate function for create the pixel spot data object
''' </param>
''' <returns></returns>
Public Iterator Function GetRasterPixels(activator As Func(Of Integer, Integer, Double, T)) As IEnumerable(Of T)
For i = 0 To m_heatMatrix.GetLength(0) - 1
For j = 0 To m_heatMatrix.GetLength(1) - 1
Expand All @@ -262,6 +281,10 @@ Namespace Drawing2D.HeatMap
Next
End Function

''' <summary>
''' populate out the default internal <see cref="PixelData"/> model
''' </summary>
''' <returns></returns>
Public Iterator Function GetRasterPixels() As IEnumerable(Of Pixel) Implements IRasterGrayscaleHeatmap.GetRasterPixels
For i = 0 To m_heatMatrix.GetLength(0) - 1
For j = 0 To m_heatMatrix.GetLength(1) - 1
Expand Down

0 comments on commit a60d252

Please sign in to comment.