Heat map generators (image, procedural) [imbSCI.Core 0.1.3.7 | imbSCI.Graph 0.1.0.30]

New versions of NuGet packages are released:

  • imbSCI.Core 0.1.3.7
  • imbSCI.Graph 0.1.0.30

Among other new classes, now you have:

  • image to heat map model converter
  • framework for procedural heat map model conversion
// namespaces relevant for the topic 
    using imbSCI.Graph.Graphics.HeatMap;
    using imbSCI.Core.math.range.matrix;

// namespaces used in examples below
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using imbSCI.Data.enums;
    using System.IO;
    using imbSCI.Core.files.folders;
    using imbSCI.Core.data;
    using imbSCI.Core.reporting.render.builders;
    using imbSCI.Graph.Graphics.HeatMap;
    using imbSCI.Core.math.range.matrix;

Two test codes with .svg result renders are presented below:

Heat map generated from jpeg image file

[TestMethod]
public void TestGrayscaleToMatrix()
{
    HeatMapRender render = new HeatMapRender();

    folderNode folder = new folderNode();
   
    String fl = folder.findFile("testArts01.jpg", SearchOption.AllDirectories);

    var map = imbSCI.Core.math.range.matrix.imageToHeatMap.CreateFromImage(fl, 100, new builderForLogBase());

    var heatMapFolder = folder.Add("HeatMap", "Heat map tests", "Folder with files produced during heat map generation test");
    render.RenderAndSave(map, heatMapFolder.pathFor("testArts01.svg"));
}

 

 

Heat map generated with two sine functions, with different weight and periods

[TestMethod]
public void TestProceduralHeatMaps()
{
    HeatMapRender render = new HeatMapRender();

    folderNode folder = new folderNode();
    var heatMapFolder = folder.Add("HeatMap", "Heat map tests", "Folder with files produced during heat map generation test");

    var sineWave = proceduralHeatMapGenerator.PresetSineWave();

    render.RenderAndSave(sineWave.MakeHeatMap(100, 50, 50,10), heatMapFolder.pathFor("sine_wave.svg", getWritableFileMode.overwrite));

    sineWave = proceduralHeatMapGenerator.PresetDoubleSineWave();
    render.RenderAndSave(sineWave.MakeHeatMap(100, 50, 50,50), heatMapFolder.pathFor("sine_double_wave.svg", getWritableFileMode.overwrite));           
}

 

 

Spread the love