ClusterDataSet() 공개 메소드

Seperates a dataset into clusters or groups with similar characteristics
public ClusterDataSet ( ClusterCollection clusters, double data ) : ClusterCollection
clusters ClusterCollection A collection of data clusters
data double An array containing data to b eclustered
리턴 ClusterCollection
예제 #1
0
        /// <summary>
        /// Test the clustering of data in an Array
        /// </summary>
        private static void ClusterDataSetTestCase()
        {
            double[][] data = DataSample.GetDataSampleFromFile(10000, 25);

            ClusterCollection clusters;
            KMeansParallel kMeans = new KMeansParallel();
            clusters = kMeans.ClusterDataSet(5, data);

            //This line has been commented out. Uncomment it to serialize your object(s)
            KMeansParallel.Serialize(clusters, @"kmeansparallelclusters.xml");
        }
        public string Apply(int k, string fn, string outImagePath)
        {
            Bitmap srcimg = new Bitmap(fn);
            pixels = ImageUtils.BitmapToArray1DIntRGB(srcimg);
            ColorHistogram colorHist = new ColorHistogram(pixels, false);
            int size = colorHist.getNumberOfColors();
            if (size <= k)
                srcimg.Save(outImagePath, ImageFormat.Png);
            else
            {
                double[][] data = new double[size][];

                getRGBData(colorHist, data);
                ClusterCollection clusters;
                KMeansParallel kMeans = new KMeansParallel();
                clusters = kMeans.ClusterDataSet(k, data);
                PaintRGB(srcimg, kMeans, clusters).Save(outImagePath, ImageFormat.Png);
            }
            return outImagePath;
        }