Esempio n. 1
0
        private void reduce()
        {
            if (inputImage != null)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                Bitmap bmp;
                ColorReduction.Reduce(inputImage, out bmp, textParam.Text);

                sw.Stop();
                float elapsed = 1.0e-3f * sw.ElapsedMilliseconds;
                SetImage((Bitmap)bmp.Clone());

                // Image differences:
                FloatImage a = new FloatImage(inputImage, 1);
                FloatImage b = new FloatImage(bmp, 1);

                // Simple differences:
                float dr    = a.MAD(b, 0);
                float dg    = a.MAD(b, 1);
                float db    = a.MAD(b, 2);
                float diff  = (dr + dg + db) / 3.0f;
                float diffw = (dr * Draw.RED_WEIGHT + dg * Draw.GREEN_WEIGHT + db * Draw.BLUE_WEIGHT) / Draw.WEIGHT_TOTAL;

                // Conical blur differences:
                a.Blur();
                b.Blur();
                dr = a.MAD(b);

                MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "Image: {5}x{6} ({7}){0}Time: {1:f3}s{0}plain MAD: {2:f5}{0}weighted MAD: {3:f5}{0}filtered MAD: {4:f5}",
                                              Environment.NewLine, elapsed, diff, diffw, dr,
                                              inputImage.Width, inputImage.Height, inputImage.PixelFormat.ToString()), "MAE Difference");
                bmp.Dispose();
            }

            StopComputation();
        }