コード例 #1
0
        public void MstQuantiztion()
        {
            CalcDistColorsWithApproximation();
            MapColorsIntoList();
            distinctColorsCount = distinctColors.Count;
            MstPrimEager mstPrim = new MstPrimEager(distinctColors.Count);

            mstPrim.GetMst();
            if (MainForm.K > mstPrim.edgeTo.Count())
            {
                MessageBox.Show("The K you provided is too high please choose a lower one");
                return;
            }
            if (MainForm.K < 0)
            {
                AutoKdetection autoKdetection = new AutoKdetection(mstPrim.edgeTo);
                MainForm.K = autoKdetection.K;
            }
            MstClustring Clusters = new MstClustring(MainForm.K, mstPrim.edgeTo);

            Clusters.GetClusters();

            for (int i = 0; i < height; ++i)
            {
                for (int j = 0; j < width; ++j)
                {
                    quantizedImageMatrix[i, j] = Clusters.Palette[Util.GetRGBInteger(quantizedImageMatrix[i, j].red, quantizedImageMatrix[i, j].green, quantizedImageMatrix[i, j].blue)];
                }
            }
        }
コード例 #2
0
        public void MstQuantiztionWithAutoKdetection()
        {
            CalcDistColorsWithApproximation();
            MapColorsIntoList();
            distinctColorsCount = distinctColors.Count;
            MstPrimEager mstPrim = new MstPrimEager(distinctColors.Count);

            mstPrim.GetMst();

            AutoKdetection autoKdetection = new AutoKdetection(mstPrim.edgeTo);
            MstClustring   Clusters       = new MstClustring(autoKdetection.K, mstPrim.edgeTo);

            Clusters.GetClusters();
            for (int i = 0; i < height; ++i)
            {
                for (int j = 0; j < width; ++j)
                {
                    quantizedImageMatrix[i, j] = Clusters.Palette[Util.GetRGBInteger(quantizedImageMatrix[i, j].red, quantizedImageMatrix[i, j].green, quantizedImageMatrix[i, j].blue)];
                }
            }
            MainForm.K = autoKdetection.K;
        }