public Bitmap MakeImage(List <double[]> data) { Console.Out.WriteLine("Generating image"); int height = data.Count; int width = data[0].Length; Console.Write("Image size: "); Console.Write(width); Console.Write(" x "); Console.Write(height); Console.Write("\n"); // using PixelFormat.Format24bppRgb makes setpixel horribly slow //var @out = new Bitmap(width, height, PixelFormat.Format24bppRgb); var @out = new Bitmap(width, height); BrightCorrection correction = BrightCorrection.BRIGHT_NONE; for (int y = 0; y < height; ++y) { Debug.Assert(data[y].Length == width); for (int x = 0; x < width; ++x) { double intensity = SpectrogramUtils.CalcIntensity(data[y][x], intensity_axis); intensity = SpectrogramUtils.BrightnessCorrection(intensity, correction); @out.SetPixel(x, (int)(height - 1 - y), palette.GetColor(intensity)); } } //@out.SetText("Spectrogram", serialized()); // save parameters return(@out); }
public Bitmap make_image(List <double[]> data) { Console.Out.WriteLine("Generating image"); int height = data.Count; int width = data[0].Length; Console.Write("image size: "); Console.Write(width); Console.Write(" x "); Console.Write(height); Console.Write("\n"); Bitmap @out = new Bitmap(width, height); BrightCorrection correction = BrightCorrection.BRIGHT_NONE; for (int y = 0; y < height; ++y) { Debug.Assert(data[y].Length == width); for (int x = 0; x < width; ++x) { double intensity = GlobalMembersSpectrogram.calc_intensity(data[y][x], intensity_axis); intensity = GlobalMembersSpectrogram.brightness_correction(intensity, correction); @out.SetPixel(x, (int)(height - 1 - y), palette.get_color(intensity)); } } //@out.SetText("Spectrogram", serialized()); // save parameters return(@out); }
public static double BrightnessCorrection(double intensity, BrightCorrection correction) { switch (correction) { case BrightCorrection.BRIGHT_NONE: return(intensity); case BrightCorrection.BRIGHT_SQRT: return(Math.Sqrt(intensity)); } Debug.Assert(false); return(0.0); }
public static double BrightnessCorrection(double intensity, BrightCorrection correction) { switch (correction) { case BrightCorrection.BRIGHT_NONE: return intensity; case BrightCorrection.BRIGHT_SQRT: return Math.Sqrt(intensity); } Debug.Assert(false); return 0.0; }