示例#1
0
        public static double getCurrentImageDisper(byte[,] src, int w, int h, ProgressBar progressBar1)
        {
            MainForm.UpdateLabel("getting Image Static Data");

            double answ = 0;
            int    ct   = 0;

            progressBar1.Minimum = 0;
            progressBar1.Maximum = h;
            byte c1, c2;

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    c1 = src[x, y];
                    if (x + 1 < w)
                    {
                        c2 = src[x + 1, y];

                        answ += diff(c1, c2);
                        ct++;
                    }
                    if (y + 1 < h)
                    {
                        c2    = src[x, y + 1];
                        answ += diff(c1, c2);
                        ct++;
                    }
                }
                progressBar1.Value = y;
            }
            return((int)(answ * 10 / ct));

            /*
             * double mid = answ / ct;
             * answ = 0;
             * ct = 0;
             *
             * for (int y = 0; y < h; y++)
             * {
             *  for (int x = 0; x < w; x++)
             *  {
             *      c1 = src[x, y];
             *      if (x + 1 < w)
             *      {
             *          c2 = src[x + 1, y];
             *
             *          answ += (mid - diff(c1, c2)) * (mid - diff(c1, c2));
             *          ct++;
             *      }
             *      if (y + 1 < h)
             *      {
             *          c2 = src[x, y + 1];
             *          answ += (mid - diff(c1, c2)) * (mid - diff(c1, c2));
             *          ct++;
             *      }
             *  }
             *  progressBar1.Value = y + h;
             * }
             * return Math.Sqrt(answ / ct);
             */
        }