/// <summary> /// This method compares the acoustic indices derived from two different long duration recordings of the same length. /// It takes as input any number of csv files of acoustic indices in spectrogram columns. /// Typically there will be at least three indices csv files for each of the original recordings to be compared. /// The method produces four spectrogram image files: /// 1) A negative false-colour spectrogram derived from the indices of recording 1. /// 2) A negative false-colour spectrogram derived from the indices of recording 2. /// 3) A spectrogram of euclidean distances bewteen the two input files. /// 4) The above three spectrograms combined in one image. /// </summary> /// <param name="inputDirectory"> /// </param> /// <param name="inputFileName1"> /// </param> /// <param name="inputFileName2"> /// </param> /// <param name="outputDirectory"> /// </param> public static void DrawDistanceSpectrogram( DirectoryInfo inputDirectory, FileInfo inputFileName1, FileInfo inputFileName2, DirectoryInfo outputDirectory) { // PARAMETERS string outputFileName1 = inputFileName1.Name; var cs1 = new LDSpectrogramRGB(minuteOffset, xScale, sampleRate, frameWidth, colorMap); cs1.ColorMode = colorMap; cs1.BackgroundFilter = backgroundFilterCoeff; string[] keys = colorMap.Split('-'); cs1.ReadCsvFiles(inputDirectory, inputFileName1.Name, keys); // ColourSpectrogram.BlurSpectrogram(cs1); // cs1.DrawGreyScaleSpectrograms(opdir, opFileName1); cs1.DrawNegativeFalseColourSpectrogram(outputDirectory, outputFileName1); string imagePath = Path.Combine(outputDirectory.FullName, outputFileName1 + ".COLNEG.png"); Image spg1Image = ImageTools.ReadImage2Bitmap(imagePath); if (spg1Image == null) { LoggedConsole.WriteLine("SPECTROGRAM IMAGE DOES NOT EXIST: {0}", imagePath); return; } int nyquist = cs1.SampleRate / 2; int herzInterval = 1000; string title = string.Format( "FALSE COLOUR SPECTROGRAM: {0}. (scale:hours x kHz) (colour: R-G-B={1})", inputFileName1, cs1.ColorMode); Image titleBar = LDSpectrogramRGB.DrawTitleBarOfFalseColourSpectrogram(title, spg1Image.Width); spg1Image = LDSpectrogramRGB.FrameLDSpectrogram( spg1Image, titleBar, cs1, nyquist, herzInterval); string outputFileName2 = inputFileName2.Name; var cs2 = new LDSpectrogramRGB(minuteOffset, xScale, sampleRate, frameWidth, colorMap); cs2.ColorMode = colorMap; cs2.BackgroundFilter = backgroundFilterCoeff; cs2.ReadCsvFiles(inputDirectory, inputFileName2.Name, keys); // cs2.DrawGreyScaleSpectrograms(opdir, opFileName2); cs2.DrawNegativeFalseColourSpectrogram(outputDirectory, outputFileName2); imagePath = Path.Combine(outputDirectory.FullName, outputFileName2 + ".COLNEG.png"); Image spg2Image = ImageTools.ReadImage2Bitmap(imagePath); if (spg2Image == null) { LoggedConsole.WriteLine("SPECTROGRAM IMAGE DOES NOT EXIST: {0}", imagePath); return; } title = string.Format( "FALSE COLOUR SPECTROGRAM: {0}. (scale:hours x kHz) (colour: R-G-B={1})", inputFileName2, cs2.ColorMode); titleBar = LDSpectrogramRGB.DrawTitleBarOfFalseColourSpectrogram(title, spg2Image.Width); spg2Image = LDSpectrogramRGB.FrameLDSpectrogram( spg2Image, titleBar, cs1, nyquist, herzInterval); string outputFileName4 = inputFileName1 + ".EuclidianDistance.png"; Image deltaSp = DrawDistanceSpectrogram(cs1, cs2); Color[] colorArray = LDSpectrogramRGB.ColourChart2Array(GetDifferenceColourChart()); titleBar = DrawTitleBarOfEuclidianDistanceSpectrogram( inputFileName1.Name, inputFileName2.Name, colorArray, deltaSp.Width, SpectrogramConstants.HEIGHT_OF_TITLE_BAR); deltaSp = LDSpectrogramRGB.FrameLDSpectrogram(deltaSp, titleBar, cs2, nyquist, herzInterval); deltaSp.Save(Path.Combine(outputDirectory.FullName, outputFileName4)); string outputFileName5 = inputFileName1 + ".2SpectrogramsAndDistance.png"; var images = new Image[3]; images[0] = spg1Image; images[1] = spg2Image; images[2] = deltaSp; Image combinedImage = ImageTools.CombineImagesVertically(images); combinedImage.Save(Path.Combine(outputDirectory.FullName, outputFileName5)); }