public void FoudForDraw(Metrica data, ref Bitmap demo, ref Color color, ref int count2)
        {
            Random rand = new Random();

            color = Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255));
            SolidBrush brush = new SolidBrush(color);
            Pen        pen   = new Pen(brush);
            int        n     = rand.Next(0, data.KeysPoint.Count);

            System.Drawing.Point cur = new System.Drawing.Point();
            cur.X = data.KeysPoint[n].X;
            cur.Y = data.KeysPoint[n].Y;
            var g = Graphics.FromImage(demo);

            g.FillRectangle(brush, cur.X, cur.Y, 12, 12);
            string drawString = count2.ToString();
            Font   drawFont   = new Font("Arial", 12, style: FontStyle.Bold);

            SolidBrush   drawBrush  = new SolidBrush(Color.Red);
            StringFormat drawFormat = new StringFormat();

            g.DrawString(drawString, drawFont, drawBrush, cur.X, cur.Y, drawFormat);
            drawFont.Dispose();
            drawBrush.Dispose();
            g.Dispose();
            count2++;
        }
        /// <summary>
        ///   Распределение ключевых точек изображения в отдельные кластеры
        /// </summary>
        /// <param name="data">Коллекция точек </param>
        /// <param name="metriks">Массив меток для каждой точки</param>
        /// <returns>Список кластеров с соответствующими точками</returns>
        private List <Metrica> Sort(double[][] data, int[] metriks)
        {
            var res          = new List <Metrica>();         // результирующий
            var countCluster = metriks.Distinct().ToArray(); // количество кластеров
            int n            = 0;
            int k            = 0;

            foreach (var numClust in countCluster)
            {
                var temp = new List <System.Drawing.Point>();
                for (int j = 0; j < metriks.Length; j++)
                {
                    if (metriks[j] == numClust)
                    {
                        temp.Add(new System.Drawing.Point((int)data[n][0], (int)data[n][1]));
                    }
                    n++;
                }
                Metrica el = new Metrica
                {
                    KeysPoint = temp,
                };
                res.Add(el);
                n = 0;
                k++;
            }
            return(res);
        }
Example #3
0
        public void VisualGraphKey(Metrica data, ref int count)
        {
            var x = data.KeysPoint.Select(_ => _.X).ToArray();
            var y = data.KeysPoint.Select(_ => _.Y).ToArray();

            approx.Series.Add("Series" + count.ToString());
            approx.Series["Series" + count.ToString()].ChartArea = "ChartArea1";
            approx.Series["Series" + count.ToString()].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
            approx.Series[count].Points.DataBindXY(x, y);
            count++;
        }