コード例 #1
0
        public void Execute()
        {
            string test   = "";
            DCT    dd     = new DCT(ImgIn.Width, ImgIn.Height);
            var    t      = dd.BitmapToMatrices(ImgIn);
            DCT    d      = new DCT(8, 8);
            int    height = ImgIn.Height - ImgIn.Height % 8;
            int    width  = ImgIn.Width - ImgIn.Width % 8;

            for (int i = 0; i < height; i += 8)
            {
                for (int j = 0; j < width; j += 8)
                {
                    double[,] r = new double[8, 8];
                    for (int q = 0; q < 8; q++)
                    {
                        for (int e = 0; e < 8; e++)
                        {
                            r[e, q] = t[0][j + e, i + q];
                        }
                    }
                    r = d.DCT2D(r);

                    if (r[7, 7] < 0)
                    {
                        test += "0";
                    }
                    else
                    {
                        test += "1";
                    }
                }
            }

            // Check mark
            for (int i = 0; i < 8; i++)
            {
                Mark = BinaryToString(test);
                int count = 0;
                foreach (var item in Mark)
                {
                    if (Char.IsLetterOrDigit(item))
                    {
                        count++;
                    }
                }
                if (count > Mark.Length / 5)
                {
                    break;
                }
                Mark = "None";
            }
        }
コード例 #2
0
        public void Execute()
        {
            DCT dd = new DCT(ImgIn.Width, ImgIn.Height);
            var t  = dd.BitmapToMatrices(ImgIn);
            DCT d  = new DCT(8, 8);
            int h  = ImgIn.Height - ImgIn.Height % 8;
            int w  = ImgIn.Width - ImgIn.Width % 8;
            int c  = 0;

            for (int i = 0; i < h; i += 8)
            {
                for (int j = 0; j < w; j += 8)
                {
                    double[,] r = new double[8, 8];
                    for (int q = 0; q < 8; q++)
                    {
                        for (int e = 0; e < 8; e++)
                        {
                            r[e, q] = t[0][j + e, i + q];
                        }
                    }
                    r = d.DCT2D(r);

                    r[7, 7] = Robustness;
                    if (Mark[c] == '0')
                    {
                        r[7, 7] = -Robustness;
                    }
                    c = (c + 1) % Mark.Length;

                    r = d.IDCT2D(r);
                    for (int q = 0; q < 8; q++)
                    {
                        for (int e = 0; e < 8; e++)
                        {
                            t[0][j + e, i + q] = r[e, q];
                        }
                    }
                }
            }

            ImgOut = dd.MatricesToBitmap(t);
        }