public double GetInternalDifferenceAssessment()
        {
            AssesmentsSegment[] segments = SegmentedSetConverter.ConvertToAssessmentSegments(m_segmentedSet, m_height, m_width, m_arrayImageCopy, m_colorSheme);

            SumOfTheInternalDispersionsAssessment assessment = new SumOfTheInternalDispersionsAssessment();

            return(assessment.GeAssessment(segments, m_colorSheme));
        }
        public string CalcAssessments()
        {
            System.Diagnostics.Debug.WriteLine("===Начало оценивания качества сегментации===" + DateTime.Now);

            string s = string.Empty;

            AssesmentsSegment[] segments = SegmentedSetConverter.ConvertToAssessmentSegments(m_segmentedSet, m_height, m_width, m_arrayImageCopy, m_colorSheme);

            AssessmentBase[] assesments = AssessmentsHelper.GetAllAssessments();
            for (int i = 0; i < assesments.Length; i++)
            {
                //assesments[i].name = $"Оцінка {i}";
                double value = assesments[i].GeAssessment(segments, m_colorSheme);

                s += $"{assesments[i].name}: {value.ToString("0.00")}" + Environment.NewLine + Environment.NewLine;

                System.Diagnostics.Debug.WriteLine($"Оценка {i} готова. " + DateTime.Now);
            }

            return(s);
        }
        public Bitmap DoSegmentation(double[,,] arrayImage, double sigma, double k, int minSize, IColorSheme colorSheme)
        {
            m_height = arrayImage.GetLength(1);
            m_width  = arrayImage.GetLength(2);

            //debug
            System.Diagnostics.Debug.WriteLine("Reading done: " + DateTime.Now);

            m_colorSheme = colorSheme;

            //препроцессинг иображения
            arrayImage = colorSheme.Convert(arrayImage);

            //сохранение для проведения оценки качества сегментации
            m_arrayImageCopy = (double[, , ])arrayImage.Clone();

            //debug
            System.Diagnostics.Debug.WriteLine("color sheme changed: " + DateTime.Now);
            //DebugImageInfo(arrayImage);

            //smoothing
            GaussianBlur gaussianBlur = new GaussianBlur();

            double[][] filter = gaussianBlur.getKernel(sigma);
            double[,,] blurredImage = DoubleArrayImageOperations.ConvolutionFilter(arrayImage, filter);

            //debug
            System.Diagnostics.Debug.WriteLine("Smooting done: " + DateTime.Now);
            //тест размещения преобразования цвета
            //arrayImage = colorSheme.Convert(arrayImage);

            //построение графа
            Edge[] edges = buildGraphByImage(blurredImage)
                           .OrderBy(el => el.w)
                           .ToArray();

            //debug
            System.Diagnostics.Debug.WriteLine("graph builded: " + DateTime.Now);

            //debugging

            System.Diagnostics.Debug.WriteLine("edges total: " + edges.Length);

            //double minWeight = edges.Min(el => el.w);
            //double maxWeight = edges.Max(el => el.w);
            //Edge[] EdgesMoreThanMin = edges.Where(el => el.w > minWeight + 0.1).ToArray();
            //Edge[] EdgesZeroWidth = edges.Where(el => el.w < 0.01).ToArray();
            //
            //Edge[] edgesHor = edges.Where(el => el.neightbourType == NeightbourType.Horizontal).ToArray();
            //Edge[] edgesVer = edges.Where(el => el.neightbourType == NeightbourType.Vertical).ToArray();
            //Edge[] edgesTopDiag = edges.Where(el => el.neightbourType == NeightbourType.TopDiagonal).ToArray();
            //Edge[] edgesBottom = edges.Where(el => el.neightbourType == NeightbourType.BottomDiagonal).ToArray();

            //сегментированный лес непересекающихся деревьев
            DisjointSet segmentedSet = SegmentOnDisjointSet(k, m_height * m_width, edges);  //картинка тут только для передачи размера потому осталась arrayImage

            //запоминание в поле для проведения оценки
            m_segmentedSet = segmentedSet;

            //debug
            System.Diagnostics.Debug.WriteLine("Segmented: " + DateTime.Now);

            //присоеденить те, что меньше min_size к соседу по ребру
            PostProcessSmallComponents(edges, segmentedSet, minSize);

            //debug
            System.Diagnostics.Debug.WriteLine("Small Component Merged: " + DateTime.Now);

            return(SegmentedSetConverter.ConvertToBitmap(segmentedSet, m_height, m_width, out m_componentLength));
            //var a = SegmentedSetConverter.ConvertToRealCoordsSegments(segmentedSet, height, width);
            //return SegmentedSetConverter.RealCoordsSegmentResultToBitmap(a);
        }