Exemplo n.º 1
0
        public void VectorsRotate120(Bitmap image, List <double[]> vector360Contur, List <double[]> vector360Hull)
        {
            int i;

            ProcessingImage             pi = new ProcessingImage();
            List <System.Drawing.Point> localPt;

            for (i = 180; i < 360; i++)
            {
                QuickHull qh    = new QuickHull();
                Contur    cont1 = new Contur();


                //медианный фильтр для шумов границ размытых объектов
                Median filter = new Median();
                filter.ApplyInPlace(image);


                //поворот на 1 градус
                Bitmap image1 = pi.RotateImg(image, i);
                image1  = pi.ProcImg(image1);
                localPt = pi.GetPoints(image1);
                //выделение выпуклой оболочки
                List <System.Drawing.Point> ConvexHullLocal = qh.quickHull(localPt);
                ConvexHullLocal = qh.DeleteAnglePoints(ConvexHullLocal);
                //и контура
                List <System.Drawing.Point> ConturLocal = cont1.kontur(image1);
                ConturLocal = cont1.DeleteAnglePoints(ConturLocal);
                Primary marks = new Primary(image1, ConturLocal, ConvexHullLocal);
                vector360Contur.Add(marks.Contour());
                vector360Hull.Add(marks.Convex());
            }
        }
Exemplo n.º 2
0
        public void addetalons(Bitmap etalon)
        {
            ProcessingImage pi = new ProcessingImage();
            List <double[]> vector360Contur    = new List <double[]>();
            List <double[]> vector360Hull      = new List <double[]>();
            List <double[]> vector180360Contur = new List <double[]>();
            List <double[]> vector180360Hull   = new List <double[]>();

            Bitmap ImageForThread1 = etalon.Clone(
                new Rectangle(0, 0, etalon.Width, etalon.Height),
                System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            Bitmap Image24 = etalon.Clone(
                new Rectangle(0, 0, etalon.Width, etalon.Height),
                System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            List <Point> localPt = new List <System.Drawing.Point>();
            Thread       t1      = new Thread(() => VectorsRotate120(ImageForThread1, vector180360Contur, vector180360Hull));

            t1.Start();
            //рассчет вектора признаков для каждого поворота
            for (int i = 0; i < 180; i++)
            {
                QuickHull qh    = new QuickHull();
                Contur    cont1 = new Contur();

                //медианный фильтр для шумов границ размытых объектов
                Median filter = new Median();
                filter.ApplyInPlace(Image24);


                //поворот на 1 градус
                Bitmap image1 = pi.RotateImg(Image24, i);
                image1  = pi.ProcImg(image1);
                localPt = pi.GetPoints(image1);
                //выделение выпуклой оболочки
                List <System.Drawing.Point> ConvexHullLocal = qh.quickHull(localPt);
                ConvexHullLocal = qh.DeleteAnglePoints(ConvexHullLocal);
                //и контура
                List <System.Drawing.Point> ConturLocal = cont1.kontur(image1);
                ConturLocal = cont1.DeleteAnglePoints(ConturLocal);
                Primary marks = new Primary(image1, ConturLocal, ConvexHullLocal);
                vector360Contur.Add(marks.Contour());
                vector360Hull.Add(marks.Convex());
                progressBar1.Value = i + 1;
                cont1 = null;
            }
            progressBar1.Value = 0;

            for (int i = 0; i < vector180360Contur.Count; i++)
            {
                vector360Contur.Add(vector180360Contur[i]);
                vector360Hull.Add(vector180360Hull[i]);
            }

            //запись в файл по 1 объекту
            //WriteToFileBegin(vector360Contur, "Contours.txt");
            //WriteToFileBegin(vector360Hull, "Hulls.txt");


            //vector360Contur = ReadFromFile("Contours.txt", 18);
            //vector360Hull = ReadFromFile("Hulls.txt", 28);


            GetConturHullCentroid(vector360Contur, vector360Hull);
            GetConturHullMedoid(vector360Contur, vector360Hull, Contourvec, Hullvec);
        }