Beispiel #1
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            points.Add(e.Location);
            Graphics g  = Graphics.FromImage(bmp);
            Brush    b1 = new SolidBrush(Color.Red);
            Brush    b2 = new SolidBrush(Color.Blue);

            Point clicked = new Point(e.X, e.Y);
            Point example = new Point();

            if (done)
            {
                //Evaluar punto de prueba una vez que el perceptron ya esta entrenado
                evaluarPunto(clicked);
                return;
            }
            if (e.Button == MouseButtons.Right)
            {
                g.FillEllipse(b1, e.X - 6, e.Y - 6, 10, 10);
                Y.Add(1);
            }
            else
            {
                g.FillEllipse(b2, e.X - 6, e.Y - 6, 10, 10);
                Y.Add(0);
            }

            //Instanciar el punto del plano con los valores dados
            PlanePoint planePoint = new PlanePoint(PointController.pixelsToPlane(clicked, bmp));

            pictureBox1.Image = bmp;
            pictureBox1.Refresh();
            planePoints.Add(planePoint);
        }
Beispiel #2
0
        private void evaluarPunto(Point p)
        {
            Graphics   g          = Graphics.FromImage(bmp);
            Brush      b1         = new SolidBrush(Color.Red);
            Brush      b2         = new SolidBrush(Color.Blue);
            double     calculo    = 0;
            PlanePoint planePoint = new PlanePoint(PointController.pixelsToPlane(p, bmp));

            calculo = (w[0] * -1 + w[1] * planePoint.X + w[2] * planePoint.Y);
            if (calculo > 0)
            {
                g.FillEllipse(b1, p.X - 6, p.Y - 6, 10, 10);
            }
            else
            {
                g.FillEllipse(b2, p.X - 6, p.Y - 6, 10, 10);
            }

            pictureBox1.Image = bmp;
            pictureBox1.Refresh();
        }
Beispiel #3
0
 public static Point planeToPixels(PlanePoint pp, Bitmap bmp)
 {
     return(planeToPixels(pp.X, pp.Y, bmp));
 }