public MapViewModel(int MapViewId = 0) { _mapViewId = MapViewId; MinValue = 1E-9; MaxValue = 1.0; AutoScale = false; ScalingTypeOptionVm = new OptionViewModel <ScalingType>(StringLookup.GetLocalizedString("Label_ScalingType") + _mapViewId, false); ScalingTypeOptionVm.PropertyChanged += (sender, args) => UpdateImages(); ColormapTypeOptionVm = new OptionViewModel <ColormapType>(StringLookup.GetLocalizedString("Label_ColormapType")); ColormapTypeOptionVm.PropertyChanged += (sender, args) => { _colormap = new Colormap(ColormapTypeOptionVm.SelectedValue); UpdateImages(); }; _colormap = new Colormap(ColormapTypeOptionVm.SelectedValue); PlotMap = new RelayCommand <object>(PlotMap_Executed); ClearMap = new RelayCommand <object>(ClearMap_Executed); ExportDataToTextCommand = new RelayCommand(() => Maps_ExportDataToText_Executed(null, null)); DuplicateWindowCommand = new RelayCommand(() => Map_DuplicateWindow_Executed(null, null)); }
public FormMicrophone() { InitializeComponent(); if (NAudio.Wave.WaveIn.DeviceCount == 0) { MessageBox.Show("No audio input devices found.\n\nThis program will now exit.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } else { cbDevice.Items.Clear(); for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++) { cbDevice.Items.Add(NAudio.Wave.WaveIn.GetCapabilities(i).ProductName); } cbDevice.SelectedIndex = 0; } for (int i = 9; i < 16; i++) { cbFftSize.Items.Add($"2^{i} ({1 << i:N0})"); } cbFftSize.SelectedIndex = 1; cmaps = Colormap.GetColormaps(); foreach (Colormap cmap in cmaps) { cbColormap.Items.Add(cmap.Name); } cbColormap.SelectedIndex = cbColormap.Items.IndexOf("Viridis"); }
/// <summary> /// Set of lines in 3D space. /// </summary> /// <param name="origin"></param> /// <param name="xAxis"></param> /// <param name="yAxis"></param> /// <param name="scale">Scaling the field extent.</param> /// <param name="field"></param> public LineBall(Plane plane, LineSet lines, RenderEffect effect = RenderEffect.DEFAULT, Colormap colormap = Colormap.Parula, bool flatten = false) { _thickness = lines.Thickness * plane.PointSize; _color = lines.Color; this._vertexSizeBytes = Marshal.SizeOf(typeof(Vector4)); this._numVertices = lines.NumPoints * 2 - lines.Lines.Length * 2; // Linelist means, all points are there twice, minus the endpoints. if (_numVertices == 0) return; this._topology = PrimitiveTopology.LineList; // Setting up the vertex buffer. if (!flatten) GenerateGeometry(plane, lines); else GenerateGeometryFlatXY(plane, lines); //this._technique = _lineEffect.GetTechniqueByName("Render"); UsedMap = colormap; _planeNormal = plane.ZAxis; _planeNormal.Normalize(); _effect = _lineEffect; SetRenderEffect(effect); this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("SCALAR", 0, Format.R32_Float, 12, 0) }); }
/// <summary> /// Set of lines in 3D space. /// </summary> /// <param name="origin"></param> /// <param name="xAxis"></param> /// <param name="yAxis"></param> /// <param name="scale">Scaling the field extent.</param> /// <param name="field"></param> public LineBall(Plane plane, LineSet lines, RenderEffect effect = RenderEffect.DEFAULT, Colormap colormap = Colormap.Parula, bool flatten = false, float flattenToTime = 0) { _thickness = lines.Thickness * plane.PointSize; _color = lines.Color; this._vertexSizeBytes = Marshal.SizeOf(typeof(Vector4)); this._numVertices = lines.NumPoints * 2 - lines.Lines.Length * 2; // Linelist means, all points are there twice, minus the endpoints. if (_numVertices == 0) { return; } this._topology = PrimitiveTopology.LineList; // Setting up the vertex buffer. if (!flatten) { GenerateGeometry(plane, lines); } else { GenerateGeometryFlatXY(plane, lines, flattenToTime); } //this._technique = _lineEffect.GetTechniqueByName("Render"); UsedMap = colormap; _planeNormal = plane.ZAxis; _planeNormal.Normalize(); _effect = _lineEffect; SetRenderEffect(effect); this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("SCALAR", 0, Format.R32_Float, 12, 0) }); }
/// <summary> /// Plane to display scalar/vector field data on. Condition: Fields domain is 2D. /// </summary> /// <param name="origin"></param> /// <param name="xAxis"></param> /// <param name="yAxis"></param> /// <param name="scale">Scaling the field extent.</param> /// <param name="field"></param> public FieldPlane(Plane plane, VectorField fields, RenderEffect effect = RenderEffect.DEFAULT, Colormap map = Colormap.Parula) { #if DEBUG // Assert that the fields are 2 dimensional. foreach(Field field in fields.Scalars) System.Diagnostics.Debug.Assert(field.Size.Length >= 2); #endif this._effect = _planeEffect; this._vertexSizeBytes = 32; this._numVertices = 6; this.UsedMap = map; this._width = fields[0].Size[0]; this._height = fields[0].Size[1]; this._invalid = fields.InvalidValue ?? float.MaxValue; this._field = fields; // Setting up the vertex buffer. GenerateGeometry(plane, fields[0].Size.ToInt2(), fields.TimeSlice??0); // Generating Textures from the fields. _fieldTextures = new ShaderResourceView[fields.Scalars.Length]; for(int f = 0; f < _field.NumVectorDimensions; ++f) { Texture2D tex = ColorMapping.GenerateTextureFromField(_device, fields[f]); _fieldTextures[f] = new ShaderResourceView(_device, tex); } this.SetRenderEffect(effect); this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("TEXTURE", 0, Format.R32G32B32A32_Float, 16, 0) }); }
public MainViewModel() { //Setup the audio input if (NAudio.Wave.WaveIn.DeviceCount == 0) { //TODO: set NoDevice app state } else { DeviceCapabilities = new List <WaveInCapabilities>(); for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++) { DeviceCapabilities.Add(NAudio.Wave.WaveIn.GetCapabilities(i)); } SelectedDevice = DeviceCapabilities[0]; } //Setup FFT size FftSizes = new List <int>() { 512, 1024, 2048, 4096, 8192, 16384, 32768 }; SelectedFftSize = FftSizes[1]; ColorMaps = Colormap.GetColormaps().ToList(); SelectedColorMap = ColorMaps.Where(c => c.Name == "Viridis").FirstOrDefault(); Brightness = 5; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(100); timer.IsEnabled = true; timer.Tick += Timer_Tick; timer.Start(); }
private void SpecInit() { foreach (string sr in sampleRates) { cbSampleRate.Items.Add(sr); } cbSampleRate.SelectedIndex = 2; //Init mic inputs into the combo box if (NAudio.Wave.WaveIn.DeviceCount == 0) { MessageBox.Show("No audio input devices found.\n\nThis program will now exit.", "ERROR", MessageBoxButton.OK); Close(); } else { cbMicInput.Items.Clear(); for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++) { cbMicInput.Items.Add(NAudio.Wave.WaveIn.GetCapabilities(i).ProductName); } cbMicInput.SelectedIndex = 0; } //Init fft settings for (int i = 9; i < 14; i++) { cbFFTsize.Items.Add($"({1 << i:N0})"); } cbFFTsize.SelectedIndex = 1; //Init fft settings for (int i = 0; i < 10; i++) { cbOverlap.Items.Add($"{i}/{(i+1)}"); } cbOverlap.SelectedIndex = 1; //Init colormaps cmaps = Colormap.GetColormaps(); foreach (Colormap cmap in cmaps) { cbCmaps.Items.Add(cmap.Name); } cbCmaps.SelectedIndex = cbCmaps.Items.IndexOf("Magma"); //Timer used to continously update the spectrogram with new data specTimer = new DispatcherTimer(); specTimer.Interval = TimeSpan.FromMilliseconds(5); specTimer.Tick += new EventHandler(SpecTimer_tick); specTimer.Start(); scrollViewerSpec.ScrollToBottom(); scrollViewerSpec.ScrollToRightEnd(); }
public class XPM : ZPixmap { // TODO public XPM(Display display, String [] xpm) : base(display) { String [] values = xpm [0].Split(new char[] { ' ' }); width = Int32.Parse(values[0]); height = Int32.Parse(values[1]); int num_colors = Int32.Parse(values[2]); int chars_per_pixel = Int32.Parse(values[3]); // TODO how to select best SUITABLE format? format = FORMAT; pixmap_format = display.default_pixmap_format; image_byte_order = display.image_byte_order; pixel_byte_count = pixmap_format.bits_per_pixel() / 8; init(); Hashtable mapping = new Hashtable(2 * num_colors); Colormap cmap = display.default_colormap; for (int i = 0; i < num_colors; i++) { String [] color = xpm [i + 1].Split(new char[] { ' ' }); String symbol = color[0]; while (color.Length > 1 && color[1].Equals("c")) // can only parse c for now { String color_value = color[2]; if (color_value[0] == '#') { int pixel = Int32.Parse( color_value.Substring(1, color_value.Length), System.Globalization.NumberStyles.HexNumber); mapping.Add(symbol, new Color(pixel)); } else // not starting with # { mapping.Add(symbol, cmap.alloc_named_color(color_value)); } } } // TODO more efficient linear for-loop for (int y = 0; y < height; y++) { String pixels = xpm [1 + num_colors + y]; for (int x = 0; x < width; x++) { String symbol = pixels.Substring(x * chars_per_pixel, (x + 1) * chars_per_pixel); Color color = (Color)mapping[symbol]; set(x, y, color.pixel); } } }
public void Test_Colormaps_ByName() { string[] names = Colormap.GetColormapNames(); Console.WriteLine(string.Join(", ", names)); Colormap viridisCmap = Colormap.GetColormap("viridis"); Assert.AreEqual("Viridis", viridisCmap.Name); }
public PlottableHeatmap(double[,] intensities, Colormap colormap, string label, double[] axisOffsets, double[] axisMultipliers, double?scaleMin, double?scaleMax, double?transparencyThreshold, Bitmap backgroundImage, bool displayImageAbove, bool drawAxisLabels) { this.width = intensities.GetLength(1); this.height = intensities.GetLength(0); double[] intensitiesFlattened = Flatten(intensities); this.min = intensitiesFlattened.Min(); this.max = intensitiesFlattened.Max(); this.brush = new SolidBrush(Color.Black); this.pen = new Pen(brush); this.axisOffsets = axisOffsets; this.axisMultipliers = axisMultipliers; this.colorMap = colormap; this.label = label; this.scaleMin = scaleMin; this.scaleMax = scaleMax; this.backgroundImage = backgroundImage; this.displayImageAbove = displayImageAbove; this.drawAxisLabels = drawAxisLabels; double normalizeMin = min; double normalizeMax = max; if (scaleMin.HasValue && scaleMin.Value < min) { normalizeMin = scaleMin.Value; } if (scaleMax.HasValue && scaleMax.Value > max) { normalizeMin = scaleMax.Value; } if (transparencyThreshold.HasValue) { this.transparencyThreshold = Normalize(new double[] { transparencyThreshold.Value }, min, max, scaleMin, scaleMax)[0]; } intensitiesNormalized = Normalize(intensitiesFlattened, null, null, scaleMin, scaleMax); int[] flatARGB = Colormap.GetRGBAs(intensitiesNormalized, colormap, minimumIntensity: transparencyThreshold ?? 0); bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); scale = new Bitmap(1, 256, PixelFormat.Format32bppArgb); double[] normalizedValues = Normalize(Enumerable.Range(0, scale.Height).Select(i => (double)i).Reverse().ToArray(), null, null, scaleMin, scaleMax); int[] scaleRGBA = Colormap.GetRGBAs(normalizedValues, colormap); Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); Rectangle rectScale = new Rectangle(0, 0, scale.Width, scale.Height); BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat); BitmapData scaleBmpData = scale.LockBits(rectScale, ImageLockMode.ReadWrite, scale.PixelFormat); Marshal.Copy(flatARGB, 0, bmpData.Scan0, flatARGB.Length); Marshal.Copy(scaleRGBA, 0, scaleBmpData.Scan0, scaleRGBA.Length); bmp.UnlockBits(bmpData); scale.UnlockBits(scaleBmpData); }
public void AddColormap(string data) { List <string> dataArray; List <string> tempData; // on sépare les données par ligne dans une liste dataArray = data.Split('\n').ToList(); // on enlève les espaces en début et fin de chaque ligne (pour ne pas avoir de ligne vide) foreach (string s in dataArray) { s.Trim(); } // on crée une colormap Colormap temp = new Colormap(dataArray.Count); // pour chaque ligne foreach (string s in dataArray) { // on extrait les données tempData = s.Split(' ').ToList(); // on crée et ajoute un Vector3 (RGB) dans la Colormap créée temp.values.Add(new Vector3(int.Parse(tempData[0]), int.Parse(tempData[1]), int.Parse(tempData[2]))); } // on ajoute la nouvelle Colormap à la liste maps.Add(temp); // on crée le prefab d'UI GameObject tempPrefab = (GameObject)Instantiate(prefabUI, new Vector3(0, 0, 0), Quaternion.identity, GameObject.FindWithTag("ColormapsPanel").transform); // on met les bons textes dans le prefab tempPrefab.GetComponentsInChildren <Text>().ElementAt(0).text = temp.size.ToString(); // on change l'ordre du prefab dans la hiérarchie tempPrefab.transform.SetSiblingIndex(tempPrefab.transform.GetSiblingIndex() - 1); // on assigne le bon callback au bouton remove tempPrefab.GetComponentInChildren <Button>().onClick.AddListener(() => RemoveColormap(tempPrefab)); // on assigne le bon callback au toggle tempPrefab.GetComponentInChildren <Toggle>().onValueChanged.AddListener(delegate { SelectColormap(); }); // on active le toggle si il n'y a qu'une seule colormap if (maps.Count == 1) { tempPrefab.GetComponentInChildren <Toggle>().isOn = true; tempPrefab.GetComponentInChildren <Toggle>().interactable = false; tempPrefab.GetComponentInChildren <Button>().interactable = false; } // on set l'index du toggle d'inversion tempPrefab.GetComponentInChildren <InverterScript>().index = maps.Count - 1; // on affiche la fenêtre pour demander un nom de colormap colormapNameWindow.SetActive(true); }
public ColorMapDialog(Colormap colormap) { Colormap = colormap; App.Core.Log("Color map editor", "0"); InitializeComponent(); App.Core.Log("Color map editor", "1"); ColorMapView.ItemsSource = colormap.Colors; App.Core.Log("Color map editor", "2"); }
/// <summary> /// This method analyzes the intensities and colormap to create a bitmap /// with a single pixel for every intensity value. The bitmap is stored /// and displayed (without anti-alias interpolation) when Render() is called. /// </summary> /// <param name="intensities">2D array of data for the heatmap (null values are not shown)</param> /// <param name="colormap">update the Colormap to use this colormap</param> /// <param name="min">minimum intensity (according to the colormap)</param> /// <param name="max">maximum intensity (according to the colormap)</param> public void Update(double?[,] intensities, Colormap colormap = null, double?min = null, double?max = null) { Width = intensities.GetLength(1); Height = intensities.GetLength(0); Colormap = colormap ?? Colormap; ScaleMin = min; ScaleMax = max; double?[] intensitiesFlattened = intensities.Cast <double?>().ToArray(); Min = double.PositiveInfinity; Max = double.NegativeInfinity; foreach (double?curr in intensitiesFlattened) { if (curr.HasValue && double.IsNaN(curr.Value)) { throw new ArgumentException("Heatmaps do not support intensities of double.NaN"); } if (curr.HasValue && curr.Value < Min) { Min = curr.Value; } if (curr.HasValue && curr.Value > Max) { Max = curr.Value; } } // labels for colorbar ticks ColorbarMin = (ScaleMin.HasValue && ScaleMin > Min) ? $"≤ {ScaleMin:f3}" : $"{Min:f3}"; ColorbarMax = (ScaleMax.HasValue && ScaleMax < Max) ? $"≥ {ScaleMax:f3}" : $"{Max:f3}"; double normalizeMin = (ScaleMin.HasValue && ScaleMin.Value < Min) ? ScaleMin.Value : Min; double normalizeMax = (ScaleMax.HasValue && ScaleMax.Value > Max) ? ScaleMax.Value : Max; if (TransparencyThreshold.HasValue) { TransparencyThreshold = Normalize(TransparencyThreshold.Value, Min, Max, ScaleMin, ScaleMax); } double?[] NormalizedIntensities = Normalize(intensitiesFlattened, null, null, ScaleMin, ScaleMax); int[] flatARGB = Colormap.GetRGBAs(NormalizedIntensities, Colormap, minimumIntensity: TransparencyThreshold ?? 0); double?[] normalizedValues = Normalize(Enumerable.Range(0, 256).Select(i => (double?)i).Reverse().ToArray(), null, null, ScaleMin, ScaleMax); int[] scaleRGBA = Colormap.GetRGBAs(normalizedValues, Colormap); BmpHeatmap?.Dispose(); BmpHeatmap = new Bitmap(Width, Height, PixelFormat.Format32bppArgb); Rectangle rect = new Rectangle(0, 0, BmpHeatmap.Width, BmpHeatmap.Height); BitmapData bmpData = BmpHeatmap.LockBits(rect, ImageLockMode.ReadWrite, BmpHeatmap.PixelFormat); Marshal.Copy(flatARGB, 0, bmpData.Scan0, flatARGB.Length); BmpHeatmap.UnlockBits(bmpData); }
public void Verify_copper_colormap() { var colorMap = new Colormap(ColormapType.Copper); var red = new double[] { 0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 30, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 95, 96, 97, 98, 100, 101, 102, 103, 104, 106, 107, 108, 109, 111, 112, 113, 114, 116, 117, 118, 120, 121, 122, 123, 125, 126, 127, 128, 129, 131, 132, 133, 134, 136, 137, 138, 140, 141, 142, 143, 145, 146, 147, 148, 150, 151, 152, 153, 154, 156, 157, 158, 159, 161, 162, 163, 165, 166, 167, 168, 170, 171, 172, 173, 174, 176, 177, 178, 179, 181, 182, 183, 184, 186, 187, 188, 190, 191, 192, 193, 195, 196, 197, 198, 199, 201, 202, 203, 204, 206, 207, 208, 210, 211, 212, 213, 215, 216, 217, 218, 220, 221, 222, 223, 224, 226, 227, 228, 229, 231, 232, 233, 235, 236, 237, 238, 240, 241, 242, 243, 244, 246, 247, 248, 249, 251, 252, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; var green = new double[] { 0, 0, 1, 2, 3, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 14, 14, 15, 16, 17, 17, 18, 19, 20, 21, 21, 22, 23, 24, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 42, 43, 44, 45, 46, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 54, 55, 56, 57, 57, 58, 59, 60, 60, 61, 62, 63, 64, 64, 65, 66, 67, 67, 68, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76, 77, 78, 78, 79, 80, 81, 82, 82, 83, 84, 85, 85, 86, 87, 88, 89, 89, 90, 91, 92, 92, 93, 94, 95, 96, 96, 97, 98, 99, 99, 100, 101, 102, 103, 103, 104, 105, 106, 107, 107, 108, 109, 110, 110, 111, 112, 113, 114, 114, 115, 116, 117, 117, 118, 119, 120, 121, 121, 122, 123, 124, 124, 125, 126, 127, 128, 128, 129, 130, 131, 132, 132, 133, 134, 135, 135, 136, 137, 138, 139, 139, 140, 141, 142, 142, 143, 144, 145, 146, 146, 147, 148, 149, 149, 150, 151, 152, 153, 153, 154, 155, 156, 157, 157, 158, 159, 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168, 169, 170, 171, 171, 172, 173, 174, 174, 175, 176, 177, 178, 178, 179, 180, 181, 182, 182, 183, 184, 185, 185, 186, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194, 195, 196, 196, 197, 198, 199 }; var blue = new double[] { 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 99, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126 }; Assert.AreEqual(red, colorMap.RedByte); Assert.AreEqual(green, colorMap.GreenByte); Assert.AreEqual(blue, colorMap.BlueByte); }
public void Verify_hsv_colormap() { var colorMap = new Colormap(ColormapType.HSV); var red = new double[] { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 247, 241, 235, 229, 223, 217, 211, 205, 199, 193, 187, 181, 175, 169, 163, 157, 151, 145, 139, 133, 127, 121, 115, 109, 103, 97, 91, 85, 79, 73, 67, 61, 55, 49, 43, 37, 31, 25, 19, 13, 7, 1, 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, 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, 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, 0, 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157, 163, 169, 175, 181, 187, 193, 199, 205, 211, 217, 223, 229, 235, 241, 247, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; var green = new double[] { 0, 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185, 191, 197, 203, 209, 215, 221, 227, 233, 239, 245, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 249, 243, 237, 231, 225, 219, 213, 207, 201, 195, 189, 183, 177, 171, 165, 159, 153, 147, 141, 135, 129, 123, 117, 111, 105, 99, 93, 87, 81, 75, 69, 63, 57, 51, 45, 39, 33, 27, 21, 15, 9, 3, 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, 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, 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, 0 }; var blue = new double[] { 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, 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, 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, 0, 0, 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165, 171, 177, 183, 189, 195, 201, 207, 213, 219, 225, 231, 237, 243, 249, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 245, 239, 233, 227, 221, 215, 209, 203, 197, 191, 185, 179, 173, 167, 161, 155, 149, 143, 137, 131, 125, 119, 113, 107, 101, 95, 89, 83, 77, 71, 65, 59, 53, 47, 41, 35, 29, 23, 17, 11, 5 }; Assert.AreEqual(red, colorMap.RedByte); Assert.AreEqual(green, colorMap.GreenByte); Assert.AreEqual(blue, colorMap.BlueByte); }
public void Verify_binary_colormap() { var colorMap = new Colormap(ColormapType.Binary); var red = new double[] { 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; var green = new double[] { 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; var blue = new double[] { 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; Assert.AreEqual(red, colorMap.RedByte); Assert.AreEqual(green, colorMap.GreenByte); Assert.AreEqual(blue, colorMap.BlueByte); }
public void Verify_jet_colormap() { var colorMap = new Colormap(ColormapType.Jet); var red = new double[] { 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 247, 243, 239, 235, 231, 227, 223, 219, 215, 211, 207, 203, 199, 195, 191, 187, 183, 179, 175, 171, 167, 163, 159, 155, 151, 147, 143, 139, 135, 131, 127 }; var green = new double[] { 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, 0, 0, 0, 0, 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 247, 243, 239, 235, 231, 227, 223, 219, 215, 211, 207, 203, 199, 195, 191, 187, 183, 179, 175, 171, 167, 163, 159, 155, 151, 147, 143, 139, 135, 131, 127, 123, 119, 115, 111, 107, 103, 99, 95, 91, 87, 83, 79, 75, 71, 67, 63, 59, 55, 51, 47, 43, 39, 35, 31, 27, 23, 19, 15, 11, 7, 3, 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, 0, 0, 0, 0, 0 }; var blue = new double[] { 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 247, 243, 239, 235, 231, 227, 223, 219, 215, 211, 207, 203, 199, 195, 191, 187, 183, 179, 175, 171, 167, 163, 159, 155, 151, 147, 143, 139, 135, 131, 127, 123, 119, 115, 111, 107, 103, 99, 95, 91, 87, 83, 79, 75, 71, 67, 63, 59, 55, 51, 47, 43, 39, 35, 31, 27, 23, 19, 15, 11, 7, 3, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Assert.AreEqual(red, colorMap.RedByte); Assert.AreEqual(green, colorMap.GreenByte); Assert.AreEqual(blue, colorMap.BlueByte); }
public PlottableVectorField(Vector2[,] vectors, double[] xs, double[] ys, string label, Color color, Colormap colormap, double scaleFactor) { //the magnitude squared is faster to compute than the magnitude double minMagnitudeSquared = vectors[0, 0].Length(); double maxMagnitudeSquared = vectors[0, 0].Length(); for (int i = 0; i < xs.Length; i++) { for (int j = 0; j < ys.Length; j++) { if (vectors[i, j].LengthSquared() > maxMagnitudeSquared) { maxMagnitudeSquared = vectors[i, j].LengthSquared(); } else if (vectors[i, j].LengthSquared() < minMagnitudeSquared) { minMagnitudeSquared = vectors[i, j].LengthSquared(); } } } double minMagnitude = Math.Sqrt(minMagnitudeSquared); double maxMagnitude = Math.Sqrt(maxMagnitudeSquared); double[,] intensities = new double[xs.Length, ys.Length]; for (int i = 0; i < xs.Length; i++) { for (int j = 0; j < ys.Length; j++) { if (colormap != null) { intensities[i, j] = (vectors[i, j].Length() - minMagnitude) / (maxMagnitude - minMagnitude); } vectors[i, j] = Vector2.Multiply(vectors[i, j], (float)(scaleFactor / (maxMagnitude * 1.2))); //This is not a true normalize } } if (colormap != null) { double[] flattenedIntensities = intensities.Cast <double>().ToArray(); arrowColors = Colormap.GetColors(flattenedIntensities, colormap); } this.vectors = vectors; this.xs = xs; this.ys = ys; this.label = label; this.color = color; this.colormap = colormap; this.scaleFactor = scaleFactor; pen = new Pen(color); pen.CustomEndCap = new AdjustableArrowCap(2, 2); }
/// <summary> /// This method analyzes the intensities and colormap to create a bitmap /// with a single pixel for every intensity value. The bitmap is stored /// and displayed (without anti-alias interpolation) when Render() is called. /// </summary> /// <param name="intensities">2D array of data for the heatmap (all values are shown)</param> /// <param name="colormap">update the Colormap to use this colormap</param> /// <param name="min">minimum intensity (according to the colormap)</param> /// <param name="max">maximum intensity (according to the colormap)</param> public void Update(double[,] intensities, Colormap colormap = null, double?min = null, double?max = null) { double?[,] tmp = new double?[intensities.GetLength(0), intensities.GetLength(1)]; for (int i = 0; i < intensities.GetLength(0); i++) { for (int j = 0; j < intensities.GetLength(1); j++) { tmp[i, j] = intensities[i, j]; } } Update(tmp, colormap, min, max); }
private void Redraw() { if (sff is null) { return; } Colormap cmap = colormaps[cbColormap.SelectedIndex]; Bitmap bmp = Spectrogram.Image.GetBitmap(sff.Ffts, cmap, tbBrightness.Value * .2, cbDecibels.Checked); pictureBox1.Image?.Dispose(); pictureBox1.Image = bmp; }
public static void PlotHeatmapGaussianNoise(Plot plt, Colormap cmap) { Random rand = new Random(0); int[] xs = DataGen.RandomNormal(rand, 10000, 25, 10).Select(x => (int)x).ToArray(); int[] ys = DataGen.RandomNormal(rand, 10000, 25, 10).Select(y => (int)y).ToArray(); double[,] intensities = Tools.XYToIntensities(Tools.IntensityMode.gaussian, xs, ys, 50, 50, 4); plt.Clear(); plt.PlotHeatmap(intensities, cmap); plt.AxisAuto(); }
public class PPM : ZPixmap { // TODO public PPM(Display display, StreamReader bin) //throws IOException // WARNING: very naive parsing : base(display) { // format String format = bin.ReadLine(); if (!(format.Equals("P6"))) { throw new Error("Unsupported format: " + format); } // dimension String dimension = bin.ReadLine(); int index = dimension.IndexOf(' '); try { width = Int32.Parse(dimension.Substring(0, index)); height = Int32.Parse(dimension.Substring( index + 1, dimension.Length)); } catch (Exception e) { throw new Error("Invalid dimension: " + dimension); } String color_count = bin.ReadLine(); // fill up data init(); Colormap cmap = display.default_colormap; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int r = bin.Read(); int g = bin.Read(); int b = bin.Read(); // FIXME cache and index color set(x, y, cmap.alloc_color8(r, g, b)); } } }
public static void PlotLineSeries(Plot plt, Colormap cmap) { int lineCount = 7; plt.Clear(); for (int i = 0; i < lineCount; i++) { double fraction = (double)i / lineCount; double[] ys = DataGen.Sin(100, 2, mult: 1 + fraction * 2); Color c = cmap.GetColor(fraction); plt.PlotSignal(ys, color: c); } plt.AxisAuto(); }
protected override void OnScreenChanged(Gdk.Screen previous_screen) { Colormap colormap = this.Screen.RgbaColormap; if (colormap == null) { colormap = this.Screen.RgbColormap; this.supportAlpha = false; } else { this.supportAlpha = true; } this.Colormap = colormap; base.OnScreenChanged(previous_screen); }
void AddColormap(List <string> data) { // on crée une colormap Colormap temp = new Colormap(int.Parse(data[1])); // on assigne son nom temp.name = data[0]; // on assigne son état inversé ou non temp.inverted = bool.Parse(data[2]); // on boucle sur toute la ligne, par pas de 3, avec temp.size nombre de pas for (int i = 0; i < temp.size; i++) { // on crée et ajoute un Vector3 (RGB) dans la Colormap créée temp.values.Add(new Vector3(int.Parse(data[3 + (i * 3)], c), int.Parse(data[4 + (i * 3)], c), int.Parse(data[5 + (i * 3)], c))); } // on ajoute la nouvelle Colormap à la liste UI.maps.Add(temp); // on crée le prefab d'UI (si il y a un endroit où le mettre) if (colormapsPanel != null) { GameObject tempPrefab = (GameObject)Instantiate(UI.prefabUI, new Vector3(0, 0, 0), Quaternion.identity, colormapsPanel); // on met les bons textes dans le prefab tempPrefab.GetComponentsInChildren <Text>().ElementAt(0).text = temp.size.ToString(); // on change l'ordre du prefab dans la hiérarchie tempPrefab.transform.SetSiblingIndex(tempPrefab.transform.GetSiblingIndex() - 1); // on assigne le bon callback au bouton remove tempPrefab.GetComponentInChildren <Button>().onClick.AddListener(() => UI.RemoveColormap(tempPrefab)); // on assigne le bon callback au toggle tempPrefab.GetComponentInChildren <Toggle>().onValueChanged.AddListener(delegate { UI.SelectColormap(); }); // on assigne le nom de la colormap tempPrefab.GetComponentsInChildren <Text>().ElementAt(1).text = temp.name; // on set l'index du toggle d'inversion tempPrefab.GetComponentInChildren <InverterScript>().index = UI.maps.Count - 1; // on update l'UI de ce toggle tempPrefab.GetComponentInChildren <InverterScript>().GetComponent <Toggle>().SetIsOnWithoutNotify(temp.inverted); } }
public static Colormap GetComplementary(Colormap map) { switch (map) { case Colormap.Parula: return(Colormap.Red); case Colormap.Gray: return(Colormap.Parula); case Colormap.ParulaIso: case Colormap.ParulaLong: return(Colormap.Heat); default: return(Colormap.Gray); } }
public VectorField(Vector2[,] vectors, double[] xs, double[] ys, Colormap colormap, double scaleFactor, Color defaultColor) { double minMagnitudeSquared = vectors[0, 0].LengthSquared(); double maxMagnitudeSquared = vectors[0, 0].LengthSquared(); for (int i = 0; i < xs.Length; i++) { for (int j = 0; j < ys.Length; j++) { if (vectors[i, j].LengthSquared() > maxMagnitudeSquared) { maxMagnitudeSquared = vectors[i, j].LengthSquared(); } else if (vectors[i, j].LengthSquared() < minMagnitudeSquared) { minMagnitudeSquared = vectors[i, j].LengthSquared(); } } } double minMagnitude = Math.Sqrt(minMagnitudeSquared); double maxMagnitude = Math.Sqrt(maxMagnitudeSquared); double[,] intensities = new double[xs.Length, ys.Length]; for (int i = 0; i < xs.Length; i++) { for (int j = 0; j < ys.Length; j++) { if (colormap != null) { intensities[i, j] = (vectors[i, j].Length() - minMagnitude) / (maxMagnitude - minMagnitude); } vectors[i, j] = Vector2.Multiply(vectors[i, j], (float)(scaleFactor / (maxMagnitude * 1.2))); } } double[] flattenedIntensities = intensities.Cast <double>().ToArray(); VectorColors = colormap is null? Enumerable.Range(0, flattenedIntensities.Length).Select(x => defaultColor).ToArray() : Colormap.GetColors(flattenedIntensities, colormap); this.Vectors = vectors; this.Xs = xs; this.Ys = ys; }
/// <summary> /// Creates window which emulates selection. /// </summary> private void CreateWindow() { this.window = new Gtk.Window(Gtk.WindowType.Toplevel); this.window.SetDefaultSize(1, 1); this.window.AppPaintable = true; this.window.Decorated = false; this.window.KeepAbove = true; this.window.SkipPagerHint = true; this.window.SkipTaskbarHint = true; this.composited = this.window.Screen.IsComposited; Colormap map = this.composited ? this.window.Screen.RgbaColormap : this.window.Screen.RgbColormap; this.window.ScreenChanged += (s, e) => this.window.Colormap = map; this.window.ExposeEvent += (object s, Gtk.ExposeEventArgs args) => { if (this.rectangle == null) { return; } using (Cairo.Context context = CairoHelper.Create(this.window.GdkWindow)) { context.Operator = Cairo.Operator.Source; if (this.composited) { context.SetSourceRGBA(0.0, 0.0, 0.0, 0.3); } else { context.SetSourceRGB(0.3, 0.3, 0.3); } context.Rectangle(0, 0, this.rectangle.Width, this.rectangle.Height); context.Fill(); context.Stroke(); } }; this.window.Colormap = map; this.window.ShowAll(); }
private void OnChangeColormap(object sender, RoutedEventArgs e) { var comboBox = sender as ComboBox; Colormap map = (Colormap)(comboBox.SelectedItem as Colormap?); _mapper.CurrentSetting.Colormap = map; // Load a new image. It is already in the VRAM, but small. BitmapImage b = new BitmapImage(); b.BeginInit(); string dir = Directory.GetCurrentDirectory(); b.UriSource = new Uri(dir + "/Framework/Renderer/Resources/Colormap" + map.ToString() + ".png"); b.EndInit(); // ... Assign Source. ColormapView.Source = b; UpdateRenderer(); }
public MeshViewModel() { MinValue = 1E-9; MaxValue = 50.0; AutoScale = false; ScalingTypeOptionVM = new OptionViewModel <ScalingType>("Scaling Type:", false); ScalingTypeOptionVM.PropertyChanged += (sender, args) => UpdateImages(); ColormapTypeOptionVM = new OptionViewModel <ColormapType>("Colormap Type:"); _colormap = new Colormap(ColormapTypeOptionVM.SelectedValue); ColormapTypeOptionVM.PropertyChanged += (sender, args) => { _colormap = new Colormap(ColormapTypeOptionVM.SelectedValue); UpdateImages(); }; ExportDataCommand = new RelayCommand(() => ExportData_Executed(null, null)); Commands.Mesh_PlotMap.Executed += Mesh_PlotMap_Executed; }
public SolidColorBrush GetBrush(double z, double zmin, double zmax) { SolidColorBrush brush = new SolidColorBrush(); Colormap.Ydivisions = (int)((zmax - zmin) / (Colormap.ColormapLength - 1)); Colormap.Ymin = zmin; Colormap.Ymax = zmax; Colormap.Ydivisions = 64; int colorIndex = (int)(((Colormap.ColormapLength - 1) * (z - zmin) + zmax - z) / (zmax - zmin)); if (colorIndex < 0) { colorIndex = 0; } if (colorIndex >= Colormap.ColormapLength) { colorIndex = Colormap.ColormapLength - 1; } brush = Colormap.ColormapBrushes()[colorIndex]; return(brush); }
//private Buffer _indices; /// <summary> /// Set of lines in 3D space. /// </summary> /// <param name="origin"></param> /// <param name="xAxis"></param> /// <param name="yAxis"></param> /// <param name="scale">Scaling the field extent.</param> /// <param name="field"></param> public Mesh(Plane plane, TileSurface surf, RenderEffect effect = RenderEffect.DEFAULT, Colormap colormap = Colormap.Parula) { _color = surf.Color; this._vertexSizeBytes = Marshal.SizeOf(typeof(Vector4)); this._topology = PrimitiveTopology.TriangleList; this. // Setting up the vertex buffer. UsedMap = colormap; _planeNormal = plane.ZAxis; _planeNormal.Normalize(); _effect = _meshEffect; SetRenderEffect(effect); GenerateGeometry(plane, surf); this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("SCALAR", 0, Format.R32_Float, 12, 0) }); }
public void Test_Make_CommonColormaps() { (double[] audio, int sampleRate) = AudioFile.ReadWAV("../../../../../data/cant-do-that-44100.wav"); int fftSize = 1 << 12; var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 700, maxFreq: 2000); spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical spec.Add(audio); // delete old colormap files foreach (var filePath in System.IO.Directory.GetFiles("../../../../../dev/graphics/", "hal-*.png")) { System.IO.File.Delete(filePath); } foreach (var cmap in Colormap.GetColormaps()) { spec.SetColormap(cmap); spec.SaveImage($"../../../../../dev/graphics/hal-{cmap.Name}.png"); Debug.WriteLine($"![](dev/graphics/hal-{cmap.Name}.png)"); } }
public FieldPlane(Plane plane, Texture2D field, Int2 texSize, float timeSlice = 0, float invalidValue = float.MaxValue, RenderEffect effect = RenderEffect.DEFAULT, Colormap map = Colormap.Parula) { this._effect = _planeEffect; this._vertexSizeBytes = 32; this._numVertices = 6; this.UsedMap = map; this._width = texSize.X; this._height = texSize.Y; this._invalid = invalidValue; // Setting up the vertex buffer. GenerateGeometry(plane, texSize, timeSlice); // Generating Textures from the fields. _fieldTextures = new ShaderResourceView[1]; _fieldTextures[0] = new ShaderResourceView(_device, field); this.SetRenderEffect(effect); this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("TEXTURE", 0, Format.R32G32B32A32_Float, 16, 0) }); }
/// <summary> /// Returns the associated colormap as texture. /// </summary> /// <param name="map"></param> /// <returns></returns> public static ShaderResourceView GetColormapTexture(Colormap map) { return _maps[(int)map]; }
public static Colormap GetComplementary(Colormap map) { switch (map) { case Colormap.Parula: return Colormap.Red; case Colormap.Gray: return Colormap.Parula; case Colormap.ParulaIso: case Colormap.ParulaLong: return Colormap.Heat; default: return Colormap.Gray; } }
public Setting(Setting cpy) { //Array.Copy(cpy.Data, _data, _data.Length); ////Array.Copy(cpy.Data, _data, cpy.Data.Length); LineSetting = cpy.LineSetting; SliceTimeMain = cpy.SliceTimeMain; SliceTimeReference = cpy.SliceTimeReference; AlphaStable = cpy.AlphaStable; IntegrationType = cpy.IntegrationType; LineX = cpy.LineX; MemberMain = cpy.MemberMain; MemberReference = cpy.MemberReference; Colormap = cpy.Colormap; StepSize = cpy.StepSize; Shader = cpy.Shader; WindowWidth = cpy.WindowWidth; Tracking = cpy.Tracking; WindowStart = cpy.WindowStart; Measure = cpy.Measure; SliceHeight = cpy.SliceHeight; IntegrationTime = cpy.IntegrationTime; DiffusionMeasure = cpy.DiffusionMeasure; VarX = cpy.VarX; VarY = cpy.VarY; StartX = cpy.StartX; StartY = cpy.StartY; EndX = cpy.EndX; EndY = cpy.EndY; DimX = cpy.DimX; DimY = cpy.DimY; Flat = cpy.Flat; Graph = cpy.Graph; Core = cpy.Core; }
public static extern Status XAllocNamedColor(Display display, Colormap colormap, string color_name, out XColor screen_def_return, out XColor exact_def_return);