Win8 Metro(C#)数字图像处理--2.52图像K均值聚类

2021-02-09 12:18

阅读:411

标签:ima   ack   html   sha   oar   函数名   循环控制   img   nim   

原文:Win8 Metro(C#)数字图像处理--2.52图像K均值聚类

??

[函数名称]

??图像KMeans聚类??????KMeansCluster(WriteableBitmap?src,int?k)

技术分享图片

/// 
        /// KMeans Cluster process.
        /// 
        /// The source image.
        /// Cluster threshould, from 2 to 255.
        /// 
        public static WriteableBitmap KMeansCluster(WriteableBitmap src,int k)////KMeansCluster
        {
            if (src != null)
            {
                int w = src.PixelWidth;
                int h = src.PixelHeight;
                WriteableBitmap dstImage = new WriteableBitmap(w, h);
                byte[] temp = src.PixelBuffer.ToArray();
                byte[] tempMask = (byte[])temp.Clone();
                int b = 0, g = 0, r = 0;
                //定义灰度图像信息存储变量
                byte[] imageData = new byte[w * h];
                //定义聚类均值存储变量(存储每一个聚类的均值)
                double[] meanCluster = new double[k];
                //定义聚类标记变量(标记当前像素属于哪一类)
                int[] markCluster = new int[w * h];
                //定义聚类像素和存储变量(存储每一类像素值之和)
                double[] sumCluster = new double[k];
                //定义聚类像素统计变量(存储每一类像素的数目)
                int []countCluster = new int[k];
                //定义聚类RGB分量存储变量(存储每一类的RGB三分量大小)
                int[] sumR = new int[k];
                int[] sumG = new int[k];
                int[] sumB = new int[k];
                //临时变量
                int sum = 0;
                //循环控制变量
                bool s = true;
                double[] mJduge = new double[k];
                double tempV = 0;
                int cou = 0;
                //获取灰度图像信息 
                for (int j = 0; j  t)
                            {
                                tempV = t;
                                cou = j;
                            }
                        }
                        countCluster[cou]++;
                        sumCluster[cou] += (double)imageData[i];
                        markCluster[i] = cou;
                    }
                    //更新聚类均值
                    for (int i = 0; i 技术分享图片

Win8 Metro(C#)数字图像处理--2.52图像K均值聚类

标签:ima   ack   html   sha   oar   函数名   循环控制   img   nim   

原文地址:https://www.cnblogs.com/lonelyxmas/p/8554508.html


评论


亲,登录后才可以留言!