Exemple #1
0
        public void corndraw(ref Particle_parameter_for_fullimg ppff, ref Image <Bgr, Byte> pic)
        {
            for (int i = 0; i < ppff.m_SourceImage.Height; i++)
            {
                for (int j = 0; j < ppff.m_SourceImage.Width; j++)
                {
                    if (ppff.m_SourceImage[i, j].Intensity > 200)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 10), new Bgr(Color.Red), 0);
                    }
                    else if (ppff.m_SourceImage[i, j].Intensity < 10)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 10), new Bgr(Color.Green), 0);
                    }
                    else if (ppff.m_SourceImage[i, j].Intensity > 100)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 10), new Bgr(Color.Blue), 0);
                    }
                }
            }
            double min = 0, max = 0;
            Point  minl = new Point(), maxl = new Point();

            CvInvoke.MinMaxLoc(ppff.m_SourceImage, ref min, ref max, ref minl, ref maxl);
            Console.WriteLine("using old method of corndraw");
        }
Exemple #2
0
        public double getweight(ref Particle_parameter_for_fullimg ppff)
        {
            double d1 = Gradient(ref ppff);
            double d2 = Saturation(ref ppff);
            double d3 = symmetric(ref ppff);
            double d4 = corner(ref ppff);

            return(getweight(d1, d2, d3, d4));
        }
Exemple #3
0
        public double corner(ref Particle_parameter_for_fullimg ppff)
        {
            //Image<Gray, byte> c = ppff.m_CornerImage.Convert<Gray, byte>();
            //byte[] data = c.Bytes;
            //double D_cono = (data[(int)(left.Y * c.Width + left.X)] + data[(int)(right.Y * c.Width + right.X)]) / 2;
            //return D_cono;
            double D_cono = (ppff.m_CornerImage[(int)left.Y, (int)left.X].Intensity + ppff.m_CornerImage[(int)right.Y, (int)right.X].Intensity) / 512d;

            //Console.WriteLine(ppff.m_CornerImage[(int)left.Y, (int)left.X].Intensity+"  " + c[(int)left.Y, (int)left.X].Intensity);
            return(D_cono);
        }
Exemple #4
0
        public double Gradient(ref Particle_parameter_for_fullimg ppff)
        {
            double D_grad  = 0;
            int    counter = 0;

            for (int x = (int)left.X; x < right.X; x++)
            {
                float y   = (float)above.FY(x);
                float y2  = (float)below.FY(x);
                float dy  = (float)above.DifferentialFY(x);
                float dy2 = (float)below.DifferentialFY(x);


                if (y > 0 && y < ppff.height)
                {
                    double gx, gy;
                    double theta1;
                    double theta2;
                    double deltheta;
                    double cs2;
                    gx       = ppff.sobelX[(int)y, x].Intensity;
                    gy       = ppff.sobelY[(int)y, x].Intensity;
                    theta1   = Math.Atan2(gy, gx);
                    theta2   = Math.Atan(dy);
                    deltheta = (theta1 - theta2);
                    cs2      = Math.Cos(deltheta);
                    cs2     *= cs2;
                    D_grad  += cs2;
                    counter++;
                }

                if (y2 > 0 && y2 < ppff.height)
                {
                    double gx, gy;
                    double theta1;
                    double theta2;
                    double deltheta;
                    double cs2;
                    gx       = ppff.sobelX[(int)y2, x].Intensity;
                    gy       = ppff.sobelY[(int)y2, x].Intensity;
                    theta1   = Math.Atan2(gy, gx);
                    theta2   = Math.Atan(dy2);
                    deltheta = (theta1 - theta2);
                    cs2      = Math.Cos(deltheta);
                    cs2     *= cs2;
                    D_grad  += cs2;
                    counter++;
                }
            }
            return(D_grad / counter);
        }
Exemple #5
0
        public double symmetric(ref Particle_parameter_for_fullimg ppff)
        {
            //double D_frst = 300;
            //for (int x = (left.X > 0) ? (int)left.X : 0; x < right.X && x < ppff.width; x++)
            //{
            //    float y = (float)above.FY(x);
            //    float y2 = (float)below.FY(x);
            //    for (int j = (y > 0) ? (int)y : 0; j < y2 && j < ppff.height; j++)
            //    {
            //        double temp = ppff.frst.GetValue(j, x);
            //        //if (temp != 0)
            //        //{
            //        //    counter++;
            //        //}
            //        if (temp < D_frst)
            //            D_frst = temp;
            //    }
            //}
            //return D_frst;
            double D_frst = 0;
            int    st     = (int)left.X;
            int    ed     = (int)right.X;

            st += (int)(width / 10);
            ed -= (int)(width / 10);
            if (st < 0)
            {
                st = 0;
            }
            if (ed > ppff.width)
            {
                ed = ppff.width;
            }
            for (int x = st; x < ed; x++)
            {
                float y  = (float)above.FY(x);
                float y2 = (float)below.FY(x);
                for (int j = (y > 0) ? (int)y : 0; j < y2 && j < ppff.height; j++)
                {
                    double temp = ppff.S_frst.Data[j, x];
                    if (temp > D_frst)
                    {
                        D_frst = temp;
                        irs    = new PointF(x, j);
                    }
                }
            }
            return(D_frst);
        }
Exemple #6
0
        public void fixtip(ref Particle_parameter_for_fullimg ppff)
        {
            Console.WriteLine("L" + left + "R" + right);
            //Image<Gray, byte> mask = new Image<Gray, byte>(ppff.m_CornerImage.Width, ppff.m_CornerImage.Height);
            //mask.SetZero();
            //mask.Draw(new CircleF(left, (float)(width / 3)), new Gray(255), 0);
            //mask.Draw(new CircleF(right, (float)(width / 3)), new Gray(255), 0);
            double localmax = double.MinValue;
            PointF maxloc   = new PointF();

            for (int i = (int)(left.Y - width / 5); i < left.Y + width / 5; ++i)
            {
                for (int j = (int)(left.X - width / 8); j < left.X + width / 8; ++j)
                {
                    if (i < 0 || j < 0 || i > ppff.m_CornerImage.Height || j > ppff.m_CornerImage.Width)
                    {
                        continue;
                    }
                    if (/*mask[i, j].Intensity > 0 &&*/ ppff.m_CornerImage[i, j].Intensity > localmax)
                    {
                        maxloc.X = j; maxloc.Y = i;
                        localmax = ppff.m_CornerImage[i, j].Intensity;
                    }
                }
            }
            left.X = maxloc.X; left.Y = maxloc.Y;

            localmax = double.MinValue;
            maxloc   = new PointF();
            for (int i = (int)(right.Y - width / 5); i < right.Y + width / 5; ++i)
            {
                for (int j = (int)(right.X - width / 8); j < right.X + width / 8; ++j)
                {
                    if (i < 0 || j < 0 || i >= ppff.m_CornerImage.Height || j >= ppff.m_CornerImage.Width)
                    {
                        continue;
                    }
                    if (/*mask[i, j].Intensity > 0 &&*/ ppff.m_CornerImage[i, j].Intensity > localmax)
                    {
                        maxloc.X = j; maxloc.Y = i;
                        localmax = ppff.m_CornerImage[i, j].Intensity;
                    }
                }
            }
            right.X = maxloc.X; right.Y = maxloc.Y;
            Console.WriteLine("L" + left + "R" + right);
            above = new Parabola(up, left, right);
            below = new Parabola(down, left, right);
        }
Exemple #7
0
        public double Saturation(ref Particle_parameter_for_fullimg ppff)
        {
            double D_satu = 0;

            double sigpscl = 0, sigpsk = 0;
            int    countera = 0, counterb = 0;

            for (int x = ((int)left.X > 0) ? (int)left.X + 30 : 30; x < right.X && x < ppff.width; x += 50)
            {
                float y  = (float)above.FY(x);
                float y2 = (float)below.FY(x);


                if (y - 20 > 0 && y - 20 < ppff.height)
                {
                    sigpsk += (ppff.saturation[(int)y - 20, x].Intensity == 0) ? 0 : 1;
                    counterb++;
                }
                if (y2 + 20 > 0 && y2 + 20 < ppff.height)
                {
                    sigpsk += (ppff.saturation[(int)y2 + 20, x].Intensity == 0) ? 0 : 1;
                    counterb++;
                }
                if (y + 20 > 0 && y + 20 < ppff.height && y + 20 < y2)
                {
                    sigpscl += (ppff.saturation[(int)y + 20, x].Intensity == 0) ? 0 : 1;
                    countera++;
                }
                if (y2 - 20 > 0 && y2 - 20 < ppff.height && y2 - 20 > y)
                {
                    sigpscl += (ppff.saturation[(int)y2 - 20, x].Intensity == 0) ? 0 : 1;
                    countera++;
                }
            }
            double alpha, beta;

            alpha  = (counterb * 1d) / (countera + counterb);
            beta   = 1 - alpha;
            D_satu = (alpha * sigpscl - beta * sigpsk) / (alpha + beta);



            return(D_satu);
        }
Exemple #8
0
        public void symmdraw(ref Particle_parameter_for_fullimg ppff, ref Image <Bgr, Byte> pic)
        {
            for (int i = 0; i < ppff.S_frst.Height; i++)
            {
                for (int j = 0; j < ppff.S_frst.Width; j++)
                {
                    if (ppff.S_frst.Data[i, j] > 1)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Red), 0);
                    }
                    else if (ppff.S_frst.Data[i, j] > 0.8)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Orange), 0);
                    }
                    else if (ppff.S_frst.Data[i, j] > 0.6)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Yellow), 0);
                    }
                    else if (ppff.S_frst.Data[i, j] > 0.4)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Green), 0);
                    }
                    else if (ppff.S_frst.Data[i, j] > 0.2)    //通过阈值判断
                    {
                        pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Blue), 0);
                    }
                    //else if (ppff.S_frst.Data[i, j] > 0)    //通过阈值判断
                    //{
                    //    pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Indigo), 0);

                    //}
                    //else
                    //{
                    //    pic.Draw(new CircleF(new PointF(j, i), 0), new Bgr(Color.Purple), 0);

                    //}
                }
            }
        }