public void RecognizeImage()
        {
            var parasitizedPath   = @"D:\Parasitized";
            var unparasitizedPath = @"D:\Uninfected";

            var converter = new PictureConverter();
            var testParasitizedImagesInput =
                converter.Convert(@"D:\Users\Дмитри\Downloads\NeuralNetwork\NeuralNetworkTests\Images\Parasitized.png");
            var testUnparasitizedImagesInput =
                converter.Convert(@"D:\Users\Дмитри\Downloads\NeuralNetwork\NeuralNetworkTests\Images\Unparasitized.png");

            var topology      = new Topology(testParasitizedImagesInput.Count, 1, 0.1, testParasitizedImagesInput.Count / 2);
            var neuralNetwork = new NeuralNetwork(topology);

            var size = 1000;

            //Обучение
            double[,] parasitizedInputs = GetData(parasitizedPath, converter, testParasitizedImagesInput, size);
            neuralNetwork.Learn(new double[] { 1 }, parasitizedInputs, 1);

            double[,] unparasitizedInputs = GetData(unparasitizedPath, converter, testParasitizedImagesInput, size);
            neuralNetwork.Learn(new double[] { 0 }, unparasitizedInputs, 1);

            var par   = neuralNetwork.Predict(testParasitizedImagesInput.Select(t => (double)t).ToArray());
            var unpar = neuralNetwork.Predict(testUnparasitizedImagesInput.Select(t => (double)t).ToArray());

            Assert.AreEqual(1, Math.Round(par.Output, 2));
            Assert.AreEqual(0, Math.Round(unpar.Output, 2));
        }
Example #2
0
        public void RecognizeImages()
        {
            var size              = 1000;
            var parasitizedPath   = @"C:\Users\sshev\source\repos\neuralNetwork\NeuralNetworkTests\Images\Parasitized.png";
            var unparasitizedPath = @"C:\Users\sshev\source\repos\neuralNetwork\NeuralNetworkTests\Images\Unparasitized.png";

            var converter = new PictureConverter();
            var testParasitizedImageInput   = converter.Convert(@"C:\Users\sshev\source\repos\neuralNetwork\NeuralNetworkTests\Images\Parasitized.png");
            var testUnparasitizedImageInput = converter.Convert(@"C:\Users\sshev\source\repos\neuralNetwork\NeuralNetworkTests\Images\Unparasitized.png");


            var topology      = new Topology(testParasitizedImageInput.Length, 1, 0.1, testParasitizedImageInput.Length / 2);
            var neuralNetwork = new NeuralNetwork(topology);

            double[,] parasitizedInputs = GetData(parasitizedPath, converter, testParasitizedImageInput, size);
            neuralNetwork.Learn(new double[] { 1 }, parasitizedInputs, 1);

            double[,] unparasitizedInputs = GetData(unparasitizedPath, converter, testParasitizedImageInput, size);
            neuralNetwork.Learn(new double[] { 0 }, unparasitizedInputs, 1);

            var par   = neuralNetwork.Predict(testParasitizedImageInput.Select(t => (double)t).ToArray());
            var unpar = neuralNetwork.Predict(testUnparasitizedImageInput.Select(t => (double)t).ToArray());

            Assert.AreEqual(1, Math.Round(par.Output, 2));
            Assert.AreEqual(0, Math.Round(unpar.Output, 2));
        }
Example #3
0
        public void ConvertTest()
        {
            var converter = new PictureConverter();
            var inputs    = converter.Convert(@"C:\Users\admsh\source\repos\NeuralNetworks\NeuralNetworksTests\Images\Parasitized.png");

            converter.Save("d:\\image.png", inputs);
        }
        public void ConvertTest()
        {
            var converter = new PictureConverter();
            var inputs    = converter.Convert(@"C:\Users\konot\source\repos\NeuralNetworks\NeuralNetworksTests\images\Parasitized.png");

            converter.Save("C:\\Users\\konot\\Downloads\\cell_images\\image.png", inputs);
        }
        public void ConvertTest()
        {
            var converter = new PictureConverter();
            var inputs    = converter.Convert(@"D:\Users\Дмитри\Downloads\NeuralNetwork\NeuralNetworkTests\Images\Parasitized.png");

            converter.Save("d:\\images.png", inputs);
        }
        public void ConvertTest()
        {
            var converter = new PictureConverter();
            var inputs    = converter.Convert(@"C:\Users\Дима\source\repos\NeuralNetwork\NeuralNetworkTests2\image\clear.png");

            converter.Save("d:\\image.png", inputs);
        }
Example #7
0
        public void ConvertTest()
        {
            var converter = new PictureConverter();
            var inputs    = converter.Convert(@"D:\Projects\neural network ii\NeuralNetworks\NeuralNetworkTests\Images\Parasitized.png");

            converter.Save("D:\\Projects\\neural network ii\\Image test\\image.png", inputs);
        }
Example #8
0
        public void SaveAfterBrightness()
        {
            var pc     = new PictureConverter();
            var pixels = pc.Convert(@"Images\Parasitized.png");

            pc.Save(@"C:\image.png", pc.Width, pc.Height, pixels);
        }
Example #9
0
 private void imageToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         var pictureConverter = new PictureConverter();
         var inputs           = pictureConverter.Convert(openFileDialog1.FileName);
         var result           = Program.Controller.ImageNetwork.Predict(inputs).Output;
     }
 }
        public void ConvertTest()
        {
            //Arrange
            var converter = new PictureConverter();
            var inputs    = converter.Convert(@"E:\Projects C#\Project1 - Lessons\FirstNeuralNetwork\NeuralNetworkClassesTests\Images\Parasitized.png");

            converter.Save("E:\\image.png", inputs);
            //Act

            //Assert
        }
Example #11
0
        public void RecognizeImageTest()
        {
            //Arrange
            var size                        = 1000;
            var parasitizedPath             = @"E:\Downloads_chrome\cell_images\Parasitized\";
            var unparasitizedPath           = @"E:\Downloads_chrome\cell_images\Uninfected\";
            var converter                   = new PictureConverter();
            var testparasitizedImageInput   = converter.Convert(@"E:\Projects C#\Project1 - Lessons\FirstNeuralNetwork\NeuralNetworkClassesTests\Images\Parasitized.png");
            var testunparasitizedImageInput = converter.Convert(@"E:\Projects C#\Project1 - Lessons\FirstNeuralNetwork\NeuralNetworkClassesTests\Images\Unparasitized.png");
            var topology                    = new Topology(testparasitizedImageInput.Count, 1, 0.1, testparasitizedImageInput.Count / 2);
            var nuralNetwork                = new NeuralNetWork(topology);

            double[,] parasitizedInputs   = GetData(parasitizedPath, converter, testparasitizedImageInput, size);
            double[,] unparasitizedInputs = GetData(unparasitizedPath, converter, testunparasitizedImageInput, size);
            //Act
            nuralNetwork.Learn(new double[] { 1 }, parasitizedInputs, 2);
            nuralNetwork.Learn(new double[] { 0 }, unparasitizedInputs, 2);
            var par   = nuralNetwork.FeedForward(testparasitizedImageInput.Select(t => (double)t).ToArray());
            var unpar = nuralNetwork.FeedForward(testunparasitizedImageInput.Select(t => (double)t).ToArray());

            //Assert
            Assert.AreEqual(1, Math.Round(par.Output, 2));
            Assert.AreEqual(0, Math.Round(unpar.Output, 2));
        }
Example #12
0
        private void imageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                var    pictureConverter = new PictureConverter();
                string path             = openFileDialog.FileName;
                pictureBoxAfter.Image = new Bitmap(Image.FromFile(path), pictureBoxAfter.Width, pictureBoxAfter.Height);
                var inputs = pictureConverter.Convert(path);
                var result = _controller.ImageNetwork.Predict(inputs);

                var convertedBitmap = pictureConverter.ConvertToBitmap(pictureConverter.Width, pictureConverter.Height, inputs);
                pictureBoxBefore.Image = new Bitmap(convertedBitmap, pictureBoxBefore.Width, pictureBoxBefore.Height);
                messageLabel.Text      = "Шанс заражения клетки малярией составляет: " + result.ToString("0.0%");
            }
        }
Example #13
0
        private static double[,] GetData(string parasitizedPath, PictureConverter converter, double[] testImageInput, int size)
        {
            var images = Directory.GetFiles(parasitizedPath);
            var result = new double[size, testImageInput.Length];

            for (int i = 0; i < size; i++)
            {
                var image = converter.Convert(images[i]);
                for (int j = 0; j < image.Length; j++)
                {
                    result[i, j] = image[j];
                }
            }
            return(result);
        }
Example #14
0
        public void RecogniseImages()
        {
            var size            = 10;  // Количество изображений в выборке для тестов
            var parasitizedPath = @"C:\Users\Roman\Desktop\datasets\malaria\Parasitized";
            var uninfectedPath  = @"C:\Users\Roman\Desktop\datasets\malaria\Uninfected";

            var converter      = new PictureConverter();
            var testImageInput = converter.Convert(@"Images\Uninfected.png");

            Topology topology = new Topology(
                inputCount: testImageInput.Length,
                outputCount: 1,
                learningRate: 0.1,
                hiddenLayersCount: new int[] { testImageInput.Length / 2 });
            var neuralNetwork = new NeuralNetwork(topology);

            // Обучаем паразитированными изображениями
            double[,] parasitizedInputs = GetInputsData(parasitizedPath, converter, testImageInput, size);
            neuralNetwork.Learn(new double[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }, parasitizedInputs, 10);

            // Обучаем здоровыми изображениями
            double[,] uninfectedInputs = GetInputsData(uninfectedPath, converter, testImageInput, size);
            neuralNetwork.Learn(new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, uninfectedInputs, 10);

            // Тестирование
            var    testParasitizedInputs = converter.Convert(@"Images\Parasitized.png").Select(x => (double)x).ToArray();
            double parasitizedOutput     = neuralNetwork.Predict(testParasitizedInputs);

            var    testUninfectedInputs = converter.Convert(@"Images\Uninfected.png").Select(x => (double)x).ToArray();
            double uninfectedOutput     = neuralNetwork.Predict(testUninfectedInputs);

            // Assert

            Assert.AreEqual(1, Math.Round(parasitizedOutput, 2));
            Assert.AreEqual(0, Math.Round(uninfectedOutput, 2));
        }
        private static double[,] GetData(string parasitizedPath, PictureConverter converter, List <int> testImagesInput, int size)
        {
            var images = new double[size, testImagesInput.Count];
            var result = Directory.GetFiles(parasitizedPath);

            for (int i = 0; i < size; i++)
            {
                var image = converter.Convert(result[i]);
                for (int j = 0; j < image.Count; j++)
                {
                    images[i, j] = image[j];
                }
            }

            return(images);
        }
        private static int[,] GetData(string parasitizedPath, PictureConverter converter, List <int> testImageInput, int size)
        {
            var images = Directory.GetFiles(parasitizedPath);
            var result = new int[size, testImageInput.Count];

            for (var i = 0; i < size; i++)
            {
                var image = converter.Convert(images[i]);
                for (var j = 0; j < image.Count; j++)
                {
                    result[i, j] = image[j];
                }
            }

            return(result);
        }