public void ReturnEmptyPointIfLastColorNotFound()
        {
            Img = new Bitmap(10, 10);

            Point actual = ColorFinder.FindLastColorLocation(Img, Color.Red);

            Assert.That(actual.IsEmpty);
        }
        public void ReturnsTheColorPresentInUnicolorImage()
        {
            Img = new Bitmap(1, 1);
            Img.SetPixel(0, 0, Color.Red);

            var actual = ColorFinder.FindColors(Img);

            Assert.That(actual.Contains(Color.FromArgb(255, 0, 0)));
        }
        public void ReturnsTheFirstPixelLocationOfTheColor()
        {
            Point expected = new Point(2516, 303);

            Img = new Bitmap(Images.PointsFullImage);

            Point actual = ColorFinder.FindFirstColorLocation(Img, NMZColors.Border);

            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        private void BTN_COLOR_FINDER_Click(object sender, EventArgs e)
        {
            filterBmp = new Bitmap(OFD.FileName);
            filterBmp = new Bitmap(filterBmp);

            MIN = int.Parse(TXT_MIN.Text);
            MAX = int.Parse(TXT_MAX.Text);

            PCT_CANVAS.Image = ColorFinder.Execute(filterBmp, MIN, MAX);
            PCT_CANVAS.Refresh();
        }
        public void ReturnsTheNumberOfTimesAColorWasFound()
        {
            Img = new Bitmap(2, 2);
            Img.SetPixel(1, 1, Color.FromArgb(255, 0, 0));
            Img.SetPixel(0, 1, Color.FromArgb(255, 0, 0));
            Img.SetPixel(1, 0, Color.FromArgb(0, 255, 0));

            var actual = ColorFinder.CountColor(Img, Color.FromArgb(255, 0, 0));


            Assert.AreEqual(2, actual);
        }
Exemple #6
0
        /// <p>
        /// Recursive method that iterates through the directory files
        /// applying the same process
        /// <p>
        private void ProcessFolder()
        {
            DirectoryInfo dirInfo = Directory.CreateDirectory(info.DirectoryName + @"\PROCESS");

            for (int i = 0; i < fileEntries.Length; i++)
            {
                try
                {
                    filterBmp = new Bitmap(fileEntries[i]);
                    ColorFinder.Execute(filterBmp, MIN, MAX).Save(dirInfo.FullName + @"\000" + i + ".PNG");
                }
                catch (Exception) { }
            }
            MyDelegates.SetControlTextValue(LBL_STAT, "Done");
        }
        public void FindsTheColorInTheLastPixel()
        {
            Img = new Bitmap(Images.LastPixel);
            List <Color> expected = new List <Color> {
                Color.FromArgb(0, 0, 0), Color.FromArgb(255, 255, 255)
            };

            var actual = ColorFinder.FindColors(Img);


            Assert.AreEqual(expected.Count, actual.Count);

            foreach (var color in expected)
            {
                Assert.That(actual.Contains(color), "Color not found : " + color);
            }
        }
Exemple #8
0
        public void ChangesTheFontColorToBlack()
        {
            var colorFinder = new ColorFinder();
            var img         = new Bitmap(Images.PointsSmallImage);

            var blackBefore     = colorFinder.FindFirstColorLocation(img, Color.FromArgb(0, 0, 0));
            var fontColorBefore = colorFinder.FindFirstColorLocation(img, NMZColors.Font);

            var newImage = imageFilterer.FilterImage(img);

            var blackAfter     = colorFinder.FindFirstColorLocation(img, Color.FromArgb(0, 0, 0));
            var fontColorAfter = colorFinder.FindFirstColorLocation(img, NMZColors.Font);

            img.Dispose();

            Assert.AreNotEqual(blackBefore, blackAfter);
            Assert.AreNotEqual(fontColorBefore, fontColorAfter);
        }
Exemple #9
0
        public void RemovesAllColorsExpectFontColor()
        {
            var img = new Bitmap(Images.PointsSmallImage);

            var expected = new List <Color> {
                Color.FromArgb(255, 255, 255), Color.FromArgb(0, 0, 0)
            };

            var imgNoColor = imageFilterer.FilterImage(img);

            var actual = new ColorFinder().FindColors(img);

            Assert.AreEqual(expected.Count, actual.Count);

            foreach (var color in expected)
            {
                Assert.That(actual.Contains(color), "Color not found : " + color);
            }

            img.Dispose();
            imgNoColor.Dispose();
        }
        public ModellManager(Device renderDevice)
        {
            this.renderDevice = renderDevice;

            antMaterial     = new Dictionary <int, Material>();
            markerMaterials = new Dictionary <int, Material>();
            colorFinder     = new ColorFinder();

            playgroundMaterial          = new Material();
            playgroundMaterial.Ambient  = Color.FromArgb(114, 114, 73);
            playgroundMaterial.Emissive = Color.FromArgb(90, 90, 58);
            playgroundMaterial.Specular = Color.FromArgb(114, 114, 73);
            colorFinder.BelegeFarbe(new Farbe(114, 114, 73));

            sugarMaterial          = new Material();
            sugarMaterial.Emissive = Color.FromArgb(200, 200, 200);
            sugarMaterial.Specular = Color.FromArgb(255, 255, 255);
            colorFinder.BelegeFarbe(new Farbe(200, 200, 200));

            bugMaterial          = new Material();
            bugMaterial.Emissive = Color.DarkBlue;
            bugMaterial.Specular = Color.FromArgb(0, 0, 150);
            colorFinder.BelegeFarbe(new Farbe(Color.DarkBlue.R, Color.DarkBlue.G, Color.DarkBlue.B));

            fruitMaterial          = new Material();
            fruitMaterial.Emissive = Color.Green;
            fruitMaterial.Specular = Color.FromArgb(0, 255, 0);
            colorFinder.BelegeFarbe(new Farbe(Color.Green.R, Color.Green.G, Color.Green.B));

            selectionMaterial          = new Material();
            selectionMaterial.Emissive = Color.FromArgb(120, 0, 0);
            selectionMaterial.Specular = Color.Red;

            fontNormal = new Font(renderDevice, new System.Drawing.Font(FONTFAMILY, FONTSIZE, FontStyle.Regular));
            fontBold   = new Font(renderDevice, new System.Drawing.Font(FONTFAMILY, FONTSIZE, FontStyle.Bold));
            line       = new Line(renderDevice);

            createResources();
        }
        public void ReturnsTheListOfColorsPresentInAnImage()
        {
            Img = new Bitmap(5, 5);
            Img.SetPixel(2, 1, Color.FromArgb(255, 0, 0));
            Img.SetPixel(1, 2, Color.FromArgb(0, 255, 0));
            Img.SetPixel(4, 4, Color.FromArgb(0, 0, 255));

            List <Color> expected = new List <Color>
            {
                Color.FromArgb(255, 0, 0),
                Color.FromArgb(0, 255, 0),
                Color.FromArgb(0, 0, 255),
                Color.FromArgb(0, 0, 0), // default color
            };

            var actual = ColorFinder.FindColors(Img);

            Assert.AreEqual(expected.Count, actual.Count);

            foreach (var color in expected)
            {
                Assert.That(actual.Contains(color), "Color not found : " + color);
            }
        }
Exemple #12
0
 public OpticalNumberRecognizer()
 {
     numberSignatureRecognizer = new NumberSignatureRecognizer();
     finder      = new ColorFinder();
     listCleaner = new ListCleaner();
 }
 public void SetUp()
 {
     ColorFinder = new ColorFinder();
 }