public void DrawTrack(IImageProcessingContext g, double sonogramFramesPerSecond, double sonogramFreqBinWidth, int sonogramHeight) { Pen p1 = new Pen(AcousticEvent.DefaultBorderColor, 2); // default colour double secondsPerTrackFrame = 1 / this.framesPerSecond; double startSec = this.timeOffset.TotalSeconds; int frame1 = (int)Math.Round(startSec * sonogramFramesPerSecond); for (int i = 1; i < this.track.Count - 1; i++) { double endSec = startSec + (i * secondsPerTrackFrame); int frame2 = (int)Math.Round(endSec * sonogramFramesPerSecond); //int freqBin = (int)Math.Round(this.MinFreq / freqBinWidth); int f1 = this.GetFrequency(i); int f1Bin = (int)Math.Round(f1 / sonogramFreqBinWidth); int y1 = sonogramHeight - f1Bin - 1; int f2 = this.GetFrequency(i + 1); int f2Bin = (int)Math.Round(f2 / sonogramFreqBinWidth); int y2 = sonogramHeight - f2Bin - 1; g.DrawLine(p1, frame1, y1, frame2, y2); //startSec = endSec; frame1 = frame2; } //g.DrawText(this.Name, Drawing.Tahoma8, Color.Black, new PointF(t1, y - 1)); }
public void DrawFreqHits(IImageProcessingContext g) { int length = this.freqHits.Length; Pen p1 = new Pen(Color.Red, 1); for (int x = 0; x < length; x++) { if (this.freqHits[x] <= 0) { continue; } int y = (int)(this.SonogramImage.Height * (1 - (this.freqHits[x] / (double)this.nyquistFreq))); //g.DrawRectangle(p1, x, y, x + 1, y + 1); g.DrawLine(p1, x, y, x, y + 1); // g.DrawTextSafe(e.Name, Drawing.Tahoma6, Color.Black, new PointF(x, y - 1)); } }
} //OverlayRainbowTransparency() /// <summary> /// superimposes a matrix of scores on top of a sonogram. USES RAINBOW PALLETTE. /// ASSUME MATRIX consists of integers >=0. /// </summary> private void OverlayDiscreteColorMatrix(IImageProcessingContext g) { int rows = this.SuperimposedDiscreteColorMatrix.GetLength(0); int cols = this.SuperimposedDiscreteColorMatrix.GetLength(1); MatrixTools.MinMax(this.SuperimposedDiscreteColorMatrix, out var min, out var max); int palleteLength = ImageTools.DarkColors.Length; //Color[] palette = { Color.Crimson, Color.Red, Color.Orange, Color.Yellow, Color.Lime, Color.Green, Color.Blue, Color.Indigo, Color.Violet, Color.Purple }; int imageHt = this.SonogramImage.Height - 1; //subtract 1 because indices start at zero for (int r = 0; r < rows; r++) { //traverse columns - skip DC column for (int c = 1; c < cols; c++) { int index = this.SuperimposedDiscreteColorMatrix[r, c]; if (index <= 0) { continue; //nothing to show } // Color pixel = bmp.GetPixel(r, imageHt - c); // if (pixel.R > 250) continue; //by-pass white // int index = (int)Math.Floor((value * 9));//get index into pallette if (index >= palleteLength) { index = index % palleteLength; } var newColor = ImageTools.DarkColors[index]; //double factor = pixel.R / (double)(255 * 1.2); //1.2 is a color intensity adjustment //int red = (int)Math.Floor(newColor.R + ((255 - newColor.R) * factor)); //int grn = (int)Math.Floor(newColor.G + ((255 - newColor.G) * factor)); //int blu = (int)Math.Floor(newColor.B + ((255 - newColor.B) * factor)); //g.DrawLine(new Pen(Color.FromRgb(red, grn, blu)), r, imageHt - c, r + 1, imageHt - c); g.DrawLine(new Pen(newColor, 1), r, imageHt - c, r + 1, imageHt - c); } } } //OverlayDiscreteColorMatrix()
/// <summary> /// WARNING: THis method is yet to be debugged and tested following move to SixLabors drawing libraries. /// superimposes a matrix of scores on top of a sonogram. /// USES A PALLETTE of ten RAINBOW colours. /// ASSUME MATRIX is NORMALIZED IN [0,1]. /// </summary> public void OverlayRainbowTransparency(IImageProcessingContext g, Image <Rgb24> bmp) { Color[] palette = { Color.Crimson, Color.Red, Color.Orange, Color.Yellow, Color.Lime, Color.Green, Color.Blue, Color.Indigo, Color.Violet, Color.Purple }; int rows = this.SuperimposedRainbowTransparency.GetLength(0); int cols = this.SuperimposedRainbowTransparency.GetLength(1); int imageHt = this.SonogramImage.Height - 1; //subtract 1 because indices start at zero for (int r = 0; r < rows; r++) { // traverse columns - skip DC column for (int c = 1; c < cols; c++) { double value = this.SuperimposedRainbowTransparency[r, c]; if (value <= 0.0) { continue; //nothing to show } var pixel = bmp[r, imageHt - c]; if (pixel.R > 250) { continue; //by-pass white } int index = (int)Math.Floor(value * 9); // get index into pallette if (index > 9) { index = 9; } var newColor = palette[index].ToPixel <Rgb24>(); double factor = pixel.R / (255 * 1.2); // 1.2 is a color intensity adjustment var red = (byte)Math.Floor(newColor.R + ((255 - newColor.R) * factor)); var grn = (byte)Math.Floor(newColor.G + ((255 - newColor.G) * factor)); var blu = (byte)Math.Floor(newColor.B + ((255 - newColor.B) * factor)); g.DrawLine(new Pen(Color.FromRgb(red, grn, blu), 1), r, imageHt - c, r + 1, imageHt - c); c++; //every second column } } } //OverlayRainbowTransparency()