public static void DrawSonogram(BaseSonogram sonogram, string path, List <AcousticEvent> predictedEvents, double threshold, double[] scores)
        {
            Log.WriteLine("# Start to draw image of sonogram.");
            bool doHighlightSubband = false; bool add1kHzLines = true;

            using (System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines))
                using (Image_MultiTrack image = new Image_MultiTrack(img))
                {
                    //img.Save(@"C:\SensorNetworks\WavFiles\temp1\testimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.AddTrack(Image_Track.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
                    if (scores != null)
                    {
                        double normMax = threshold * 4; //so normalised eventThreshold = 0.25
                        for (int i = 0; i < scores.Length; i++)
                        {
                            scores[i] /= normMax;
                            if (scores[i] > 1.0)
                            {
                                scores[i] = 1.0;
                            }
                            if (scores[i] < 0.0)
                            {
                                scores[i] = 0.0;
                            }
                        }

                        image.AddTrack(Image_Track.GetScoreTrack(scores, 0.0, 1.0, 0.25));
                    }
                    image.AddEvents(predictedEvents);
                    image.Save(path);
                }
        }
Example #2
0
        }//end CaneToadRecogniser

        public static void DrawSonogram(BaseSonogram sonogram, string path, double[,] hits, double[] scores,
                                        List <AcousticEvent> predictedEvents, double eventThreshold, double[] intensity)
        {
            Log.WriteLine("# Start to draw image of sonogram.");
            bool doHighlightSubband = false;
            bool add1kHzLines       = true;

            //double maxScore = 50.0; //assumed max posisble oscillations per second

            using (System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines, doMelScale: false))
                using (Image_MultiTrack image = new Image_MultiTrack(img))
                {
                    //img.Save(@"C:\SensorNetworks\WavFiles\temp1\testimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
                    image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram));
                    image.AddTrack(ImageTrack.GetScoreTrack(scores, 0.0, 1.0, eventThreshold));

                    //double maxScore = 100.0;
                    //image.AddSuperimposedMatrix(hits, maxScore);
                    if (intensity != null)
                    {
                        double min, max;
                        DataTools.MinMax(intensity, out min, out max);
                        double threshold_norm = eventThreshold / max; //min = 0.0;
                        intensity = DataTools.normalise(intensity);
                        image.AddTrack(ImageTrack.GetScoreTrack(intensity, 0.0, 1.0, eventThreshold));
                    }

                    image.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
                    image.Save(path);
                }
        }
        public static void DrawSonogram(BaseSonogram sonogram, string path, double[] array1, double[] array2, List <double[]> scores)
        {
            Log.WriteLine("# Draw image of sonogram.");
            bool doHighlightSubband = false; bool add1kHzLines = true;
            //sonogram.FramesPerSecond = 1 / sonogram.FrameOffset;
            int length = sonogram.FrameCount;

            int maxIndex1 = DataTools.GetMaxIndex(array1);
            int maxIndex2 = DataTools.GetMaxIndex(array2);

            using (System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines))
                using (Image_MultiTrack image = new Image_MultiTrack(img))
                {
                    //img.Save(@"C:\SensorNetworks\WavFiles\temp1\testimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
                    image.AddTrack(ImageTrack.GetScoreTrack(DataTools.ScaleArray(array1, length), 0.0, array1[maxIndex1], 5));
                    image.AddTrack(ImageTrack.GetScoreTrack(DataTools.ScaleArray(array2, length), 0.0, array2[maxIndex2], 0.5));
                    for (int i = 0; i < scores.Count; i++)
                    {
                        int    maxIndex = DataTools.GetMaxIndex(scores[i]);
                        double max      = scores[i][maxIndex];
                        if (max <= 0.0)
                        {
                            max = 1.0;
                        }
                        image.AddTrack(ImageTrack.GetScoreTrack(DataTools.ScaleArray(scores[i], length), 0.0, max, 0.1));
                    }
                    image.Save(path);
                }// using
        }
        public static void DrawSonogram(BaseSonogram sonogram, FileInfo path, List <AcousticEvent> predictedEvents, List <double> thresholdList, List <double[]> scoresList)
        {
            Log.WriteLine("# Start to draw image of sonogram.");
            bool doHighlightSubband = false; bool add1kHzLines = true;

            // DO NOT NEED FOLLOWING TWO LINES BECAUSE HAVE CHANGED CODE TO ENSURE THAT ALL TEMPLATES USE THE SAME FRAME OVERLAP
            // AND THEREFORE ALL SCORE ARRAYS ARE OF THE SAME LENGTH FOR GIVEN RECORDING
            //Log.WriteLine("# Convert score arrays to correct length for display = {0}.", sonogram.FrameCount);
            //scoresList = ConvertScoreArrayLengths(scoresList, sonogram.FrameCount);

            // DO NOT NEED FOLLOWING LINES BECAUSE HAVE CHANGED CODE TO ENSURE THAT ALL TEMPLATES USE THE SAME FRAME OVERLAP
            // AND THEREFORE ALL SCORE ARRAYS ARE OF THE SAME LENGTH FOR GIVEN RECORDING
            // Edit the events because they will not necessarily correspond to the timescale of the display image
            //Log.WriteLine("# Convert time scale of events.");
            //foreach (AcousticEvent ae in predictedEvents)
            //{
            //    Log.WriteLine("# Event frame= {0} to {1}.", ae.oblong.RowTop, ae.oblong.RowBottom);
            //    ae.FrameOffset = sonogram.FrameOffset;
            //    ae.FramesPerSecond = sonogram.FramesPerSecond;
            //    ae.oblong = AcousticEvent.ConvertEvent2Oblong(ae);
            //    Log.WriteLine("# Event time = {0:f2} to {1:f2}.", ae.StartTime, ae.EndTime);
            //    Log.WriteLine("# Event frame= {0} to {1}.", ae.oblong.RowTop, ae.oblong.RowBottom);
            //}

            using (System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines))
                using (Image_MultiTrack image = new Image_MultiTrack(img))
                {
                    //img.Save(@"C:\SensorNetworks\WavFiles\temp1\testimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));

                    // Add in score tracks
                    for (int s = 0; s < scoresList.Count; s++)
                    {
                        if (scoresList[s] == null)
                        {
                            continue;
                        }
                        double[] scores = scoresList[s];

                        double normMax = thresholdList[s] * 4; //so normalised eventThreshold = 0.25
                        for (int i = 0; i < scores.Length; i++)
                        {
                            scores[i] /= normMax;
                            if (scores[i] > 1.0)
                            {
                                scores[i] = 1.0;
                            }
                            if (scores[i] < 0.0)
                            {
                                scores[i] = 0.0;
                            }
                        }

                        image.AddTrack(ImageTrack.GetScoreTrack(scores, 0.0, 1.0, 0.25));
                    } //end adding in score tracks

                    image.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
                    image.Save(path.FullName);
                }// using
        } // DrawSonogram()
Example #5
0
        private static void DrawWaveforms(AudioRecording recording, string path)
        {
            int imageWidth  = 284;
            int imageHeight = 60;
            var image2      = new Image_MultiTrack(recording.GetWaveForm(imageWidth, imageHeight));

            //path = outputFolder + wavFileName + "_waveform.png";
            image2.Save(path);

            double dBMin  = -25.0; //-25 dB appear to be good value
            var    image6 = new Image_MultiTrack(recording.GetWaveFormInDecibels(imageWidth, imageHeight, dBMin));

            //path = outputFolder + wavFileName + "_waveformDB.png"
            image6.Save(path);
        }
Example #6
0
        public static void DrawSonogram(BaseSonogram sonogram, string path, AcousticEvent ae)
        {
            Log.WriteLine("# Start to draw image of sonogram.");
            bool doHighlightSubband = false; bool add1kHzLines = true;

            using (Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines))
                using (Image_MultiTrack image = new Image_MultiTrack(img))
                {
                    //img.Save(@"C:\SensorNetworks\WavFiles\temp1\testimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
                    image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram));
                    var aes = new List <AcousticEvent>();
                    aes.Add(ae);
                    image.AddEvents(aes, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
                    image.Save(path);
                }
        } //end DrawSonogram
Example #7
0
        }//end Execute_Segmentation

        public static void DrawSonogram(BaseSonogram sonogram, string path, List <AcousticEvent> predictedEvents, double eventThreshold, double[] segmentation)
        {
            Log.WriteLine("# Start sono image.");
            bool doHighlightSubband = false;
            bool add1kHzLines       = true;

            //double maxScore = 50.0; //assumed max posisble oscillations per second

            using (System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines, doMelScale: false))
                using (Image_MultiTrack image = new Image_MultiTrack(img))
                {
                    //img.Save(@"C:\SensorNetworks\WavFiles\temp1\testimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
                    image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram));
                    image.AddTrack(ImageTrack.GetScoreTrack(segmentation, 0.0, 1.0, eventThreshold));
                    image.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
                    image.Save(path);
                }
        }