Exemplo n.º 1
0
        private static Rectangle GetRectangleMask(Bitmap mask)
        {
            Matrix matr = ImgConverter.BmpToMatr(mask);

            int startX = 0, endX = 0, startY = 1, endY = mask.Height;

            for (int i = 1; i < mask.Width; i++)
            {
                for (int j = startY; j < endY; j++)
                {
                    if (matr[j, i - 1] < 0.1 && matr[j, i] > 0.1)
                    {
                        startX = i;
                    }
                    if (matr[j, i - 1] > 0.1 && matr[j, i] < 0.1)
                    {
                        endX = i;
                        goto r;
                    }
                    if (matr[j - 1, i] < 0.1 && matr[j, i] > 0.1)
                    {
                        startY = j;
                    }
                    if (matr[j - 1, i] > 0.1 && matr[j, i] < 0.1)
                    {
                        endY = j;
                    }
                }
            }

r:

            return(new Rectangle(startX, startY, endX - startX, endY - startY));
        }
Exemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            string path = "1.jpg";

            Bitmap bitmap = ImgConverter.GetBitmap(path);

            matrix = ImgConverter.BmpToMatr(bitmap);
            heatMapControl1.CalculateHeatMap(matrix);
        }
Exemplo n.º 3
0
        public GanDemo()
        {
            InitializeComponent();

            generator.AddNewLayer(new Shape(5), new Flatten());
            generator.AddNewLayer(new FeedForwardLayer(10 * 10 * 2, new ReLU(0.2)));
            generator.AddNewLayer(new ReShape(new Shape(10, 10, 2)));
            generator.AddNewLayer(new ConvolutionLayer(new ReLU(0.2), 7, 3, 3)
            {
                IsSame = true
            });
            generator.AddNewLayer(new Upsampling2dBicibic());
            generator.AddNewLayer(new ConvolutionLayer(new ReLU(0.2), 6, 4, 4)
            {
                IsSame = true
            });
            generator.AddNewLayer(new Upsampling2dBicibic());
            generator.AddNewLayer(new ConvolutionLayer(new ReLU(0.2), 4, 3, 3)
            {
                IsSame = true
            });
            generator.AddNewLayer(new ConvolutionLayer(new TanhUnit(), 1, 3, 3)
            {
                IsSame = true
            });


            discriminator.AddNewLayer(generator.OutputShape, new ConvolutionLayer(new ReLU(0.2), 4, 3, 3));
            discriminator.AddNewLayer(new MaxPooling());
            discriminator.AddNewLayer(new ConvolutionLayer(new ReLU(0.2), 8, 3, 3));
            discriminator.AddNewLayer(new MaxPooling());
            discriminator.AddNewLayer(new Flatten());
            discriminator.AddNewLayer(new FeedForwardLayer(32, new ReLU(0.2)));
            discriminator.AddNewLayer(new FeedForwardLayer(1, new SigmoidWithBCE()));

            gan = new GanNet(generator, discriminator);

            matrices = new Matrix[1];
            Bitmap bitmap = new Bitmap("ganData\\1.jpg");

            bitmap      = new Bitmap(bitmap, generator.OutputShape.W, generator.OutputShape.H);
            matrices[0] = ImgConverter.BmpToMatr(bitmap);
        }