/// <summary> /// This HSL values in this method have been set specially for use with the high-resolution zooming spectrograms. /// There are limits to the values that can be used. /// The purpose for chaning the default values was to increase the colour saturation. /// </summary> public static CubeHelix GetCubeHelix() { //Hsl colorARgb = new Hsl(300, 0.5, 0.0); // DEFAULT - used prior to 26 June 2015 //Hsl colorBRgb = new Hsl(-240, 0.5, 1.0); // DEFAULT - used prior to 26 June 2015 Hsl colorARgb = new Hsl(300, 0.85f, 0.0f); Hsl colorBRgb = new Hsl(-240, 0.5f, 1.0f); var cch = new CubeHelix(colorARgb, colorBRgb); cch.SetDefaultCubeHelix(); return(cch); }
/** * Obtained from following website. * https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/ * * cubehelix.js# * * (function() { * var radians = Math.PI / 180; * * d3.scale.cubehelix = function() { * return d3.scale.linear() * .range([d3.hsl(300, .5, 0), d3.hsl(-240, .5, 1)]) * .interpolate(d3.interpolateCubehelix); * }; * * d3.interpolateCubehelix = d3_interpolateCubehelix(1); * d3.interpolateCubehelix.gamma = d3_interpolateCubehelix; * * function d3_interpolateCubehelix(gamma) { * return function(a, b) { * a = d3.hsl(a); * b = d3.hsl(b); * * var ah = (a.h + 120) * radians, * bh = (b.h + 120) * radians - ah, * as = a.s, * bs = b.s - as, * al = a.l, * bl = b.l - al; * * if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; * if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; * * return function(t) { * var h = ah + bh * t, * l = Math.pow(al + bl * t, gamma), * a = (as + bs * t) * l * (1 - l); * return "#" + hex(l + a * (-0.14861 * Math.cos(h) + 1.78277 * Math.sin(h))) + hex(l + a * (-0.29227 * Math.cos(h) - 0.90649 * Math.sin(h))) + hex(l + a * (+1.97294 * Math.cos(h))); + }; + }; + } + + function hex(v) { + var s = (v = v <= 0 ? 0 : v >= 1 ? 255 : v * 255 | 0).toString(16); + return v < 0x10 ? "0" + s : s; + } + * * * * **/ public static void DrawTestImage() { //Hsl colorARgb = new Hsl(300, 0.5, 0.0); //Hsl colorBRgb = new Hsl(-240, 0.5, 1.0); Hsl colorARgb = new Hsl(300, 0.5f, 0.0f); Hsl colorBRgb = new Hsl(-240, 0.5f, 1.0f); var cch = new CubeHelix(colorARgb, colorBRgb); cch.SetDefaultCubeHelix(); string path = @"C:\SensorNetworks\Output\FalseColourSpectrograms\SpectrogramZoom\ZoomImages\testImage.png"; cch.TestImage(path); }
/// <summary> /// This HSL values in this method have been set specially for use with the high-resolution zooming spectrograms. /// There are limits to the values that can be used. /// The purpose for chaning the default values was to increase the colour saturation. /// </summary> /// <returns></returns> public static CubeHelix GetCubeHelix() { //Hsl colorARgb = new Hsl(300, 0.5, 0.0); // DEFAULT - used prior to 26 June 2015 //Hsl colorBRgb = new Hsl(-240, 0.5, 1.0); // DEFAULT - used prior to 26 June 2015 Hsl colorARgb = new Hsl(); colorARgb.H = 300; colorARgb.S = 0.85; colorARgb.L = 0.1; Hsl colorBRgb = new Hsl(); //colorBRgb.H = -240; colorBRgb.H = -240; colorBRgb.S = 0.5; colorBRgb.L = 1.0; var cch = new CubeHelix(colorARgb, colorBRgb); cch.SetDefaultCubeHelix(); return(cch); }