/// <summary> /// superimposes a matrix of scores on top of a sonogram. /// Only draws lines on every second row so that the underling sonogram can be discerned. /// </summary> public void OverlayMatrix(IImageProcessingContext g) { //int paletteSize = 256; var pens = ImageTools.GetRedGradientPalette(); //size = 256 int rows = this.SuperimposedMatrix.GetLength(0); int cols = this.SuperimposedMatrix.GetLength(1); int imageHt = this.SonogramImage.Height - 1; //subtract 1 because indices start at zero //ImageTools.DrawMatrix(DataTools.MatrixRotate90Anticlockwise(this.SuperimposedMatrix), @"C:\SensorNetworks\WavFiles\SpeciesRichness\Dev1\superimposed1.png", false); // traverse columns - skip DC column for (int c = 1; c < cols; c++) { for (int r = 0; r < rows; r++) { if (this.SuperimposedMatrix[r, c] == 0.0) { continue; } double normScore = this.SuperimposedMatrix[r, c] / this.superImposedMaxScore; //int penID = (int)(paletteSize * normScore); //if (penID >= paletteSize) penID = paletteSize - 1; var brush = new SolidBrush(Color.Red); g.FillRectangle(brush, r, imageHt - c, 1, 1); //THIS DRAWS A PIXEL !!!! } //c++; //only draw on every second row. } }