public Bitmap GetBitmap()
        {
            Bitmap b = new Bitmap(Width, Height);

            BitmapVector c = this.Clone();

            c = c.Scale();

            if (!c.matrix[0, 0].Equals(double.NaN))
            {
                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        try
                        {
                            b.SetPixel(x, y, Color.FromArgb((int)(c.matrix[x, y] * 255.0), (int)(c.matrix[x, y] * 255.0), (int)(c.matrix[x, y] * 255.0)));
                        }
                        catch (ArgumentException)
                        {
                            // TODO - c is usually filled with NaN if you get here
                        }
                    }
                }
            }
            else
            {
                // TODO - hmmm...
            }

            return(b);
        }
Ejemplo n.º 2
0
        public BitmapVector GetClosestMatch(BitmapVector v)
        {
            if (vectors.Count == 0)
            {
                throw new CaptchaSolverException("There are no patterns loaded to match a sample pattern to!");
            }

            int    index = 0;
            double best  = BitmapVector.RootMeanSquareDistance(vectors[0].Scale(), v.Scale());

            //vectors[0].GetBitmap().Save("getmatch-a--" + index.ToString() + ".bmp");
            //v.GetBitmap().Save("getmatch--b-" + index.ToString() + ".bmp");
            //(vectors[0].Scale() - v.Scale()).GetBitmap().Save("getmatch-ab-" + index.ToString() + ".bmp");

            //for (int i = 1; i < vectors.Count; i++)
            Parallel.For(1, vectors.Count, i =>
            {
                //vectors[i].GetBitmap().Save("getmatch-a--" + i.ToString() + ".bmp");
                //v.GetBitmap().Save("getmatch--b-" + i.ToString() + ".bmp");
                //(vectors[i].Scale() - v.Scale()).GetBitmap().Save("getmatch-ab-" + i.ToString() + ".bmp");

                double test = BitmapVector.RootMeanSquareDistance(vectors[i].Scale(), v.Scale());

                if (test < best)
                {
                    best  = test;
                    index = i;
                }
            });

            return(vectors[index]);
        }
Ejemplo n.º 3
0
        public BitmapVector GetClosestMatch(BitmapVector v)
        {
            if (vectors.Count == 0)
            {
                throw new CaptchaSolverException("There are no patterns loaded to which a sample pattern may be matched!");
            }

            int    index = 0;
            double best  = BitmapVector.RootMeanSquareDistance(vectors[0].Scale(), v.Scale());

            Parallel.For(1, vectors.Count, i =>
            {
                double test = BitmapVector.RootMeanSquareDistance(vectors[i].Scale(), v.Scale());

                if (test < best)
                {
                    best  = test;
                    index = i;
                }
            });

            return(vectors[index]);
        }
        public BitmapVector GetClosestMatch(BitmapVector v)
        {
            if (vectors.Count == 0)
            {
                throw new CaptchaSolverException("There are no patterns loaded to match a sample pattern to!");
            }

            int index = 0;
            double best = BitmapVector.RootMeanSquareDistance(vectors[0].Scale(), v.Scale());

            //vectors[0].GetBitmap().Save("getmatch-a--" + index.ToString() + ".bmp");
            //v.GetBitmap().Save("getmatch--b-" + index.ToString() + ".bmp");
            //(vectors[0].Scale() - v.Scale()).GetBitmap().Save("getmatch-ab-" + index.ToString() + ".bmp");

            //for (int i = 1; i < vectors.Count; i++)
            Parallel.For(1, vectors.Count, i =>
            {
                //vectors[i].GetBitmap().Save("getmatch-a--" + i.ToString() + ".bmp");
                //v.GetBitmap().Save("getmatch--b-" + i.ToString() + ".bmp");
                //(vectors[i].Scale() - v.Scale()).GetBitmap().Save("getmatch-ab-" + i.ToString() + ".bmp");

                double test = BitmapVector.RootMeanSquareDistance(vectors[i].Scale(), v.Scale());

                if (test < best)
                {
                    best = test;
                    index = i;
                }
            });

            return vectors[index];
        }
        public BitmapVector GetClosestMatch(BitmapVector v)
        {
            if (vectors.Count == 0)
            {
                throw new CaptchaSolverException("There are no patterns loaded to which a sample pattern may be matched!");
            }

            int index = 0;
            double best = BitmapVector.RootMeanSquareDistance(vectors[0].Scale(), v.Scale());

            Parallel.For(1, vectors.Count, i =>
            {
                double test = BitmapVector.RootMeanSquareDistance(vectors[i].Scale(), v.Scale());

                if (test < best)
                {
                    best = test;
                    index = i;
                }
            });

            return vectors[index];
        }