public void GenerateField(bool update_filters = false)
        {
            dominoes = new int[length, height];
            System.Drawing.Image i;
            if (!update_filters)
            {
                using (var bmpTemp = new System.Drawing.Bitmap(SourcePath))
                {
                    i = new System.Drawing.Bitmap(bmpTemp);
                }
            }
            else
            {
                i = ImageHelper.BitmapImageToBitmap(filters.preview);
            }
            if (length < 2)
            {
                m_length = 2;
            }
            if (height < 2)
            {
                m_height = 2;
            }
            System.Drawing.Bitmap   thumb    = new System.Drawing.Bitmap(length, height);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(thumb);
            graphics.Clear(System.Drawing.Color.White);
            if (ResizeMode == 0)
            {
                graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
            }
            if (ResizeMode == 1)
            {
                graphics.InterpolationMode = InterpolationMode.Bicubic;
            }
            if (ResizeMode == 2)
            {
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            }
            System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
            System.Drawing.Imaging.ImageAttributes Att  = new System.Drawing.Imaging.ImageAttributes();
            Att.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
            graphics.DrawImage(i, new System.Drawing.Rectangle(0, 0, length, height), 0, 0, i.Width, i.Height, System.Drawing.GraphicsUnit.Pixel, Att);
            //graphics.DrawImage(i, 0, 0, length, height);
            BitmapImage     bitmapImage = ImageHelper.BitmapToBitmapImage(thumb);
            BitmapSource    bitm        = new FormatConvertedBitmap(bitmapImage, PixelFormats.Bgr24, null, 0);
            WriteableBitmap b           = BitmapFactory.ConvertToPbgra32Format(bitm);

            IColorSpaceComparison comp;

            switch (ColorRegressionMode)
            {
            case 0: comp = new CmcComparison(); break;

            case 1: comp = new Cie1976Comparison(); break;

            case 2: comp = new Cie94Comparison(); break;

            default: comp = new CieDe2000Comparison(); break;
            }

            Dithering d;

            switch (DiffusionMode)
            {
            case 0: d = new NoDithering(comp, Colors); break;

            case 1: d = new FloydSteinbergDithering(comp, Colors); break;

            case 2: d = new JarvisJudiceNinkeDithering(comp, Colors); break;

            default: d = new StuckiDithering(comp, Colors); break;
            }
            dominoes = d.Dither(b, comp);

            b.Lock();
        }