예제 #1
0
        private void voPB_MouseClick(object aoSender, MouseEventArgs aoArgs)
        {
            PictureBox koPB = aoSender as PictureBox;
            int        kiX  = aoArgs.X;
            int        kiY  = aoArgs.Y;
            int        kiI  = (kiY * this.voOrig.Width) + kiX;
            double     kdPm;
            int        kiC;
            Bitmap     koBmp = ( Bitmap )this.voOrig.Clone( );

            try
            {
                // Gamma matrix has the probabilities for a data point for its membership in each cluster
                kiC  = 0;
                kdPm = this.voGmmnd.Gamma[kiI, 0];
                for (int m = 0; m < this.voGmmnd.ViK; m++)
                {
                    if (this.voGmmnd.Gamma[kiI, m] > kdPm)
                    {
                        kiC  = m; // data i belongs to cluster m
                        kdPm = this.voGmmnd.Gamma[kiI, m];
                    }
                }

                MyImageProc.DrawCluster(this.voPB, this.mClusterPoints( ), ref koBmp, 1, kiC);
            }
            catch (Exception koEx)
            {
                Console.WriteLine(koEx.Message);
            }
        }
예제 #2
0
        private void voLB_SelectedIndexChanged(object aoSender, EventArgs aoArgs)
        {
            ListBox koLB = aoSender as ListBox;
            Bitmap  koBmp;

            if (koLB.SelectedIndex >= 0)
            {
                koBmp = ( Bitmap )this.voOrig.Clone( );
                MyImageProc.DrawCluster(this.voPB, this.mClusterPoints( ), ref koBmp, 1, koLB.SelectedIndex);
            }
            else
            {
                this.voPB.Image = null;
                this.voPB.Image = this.voOrig;
            }
        }
예제 #3
0
        private void voBtnShowBall_Click(object sender, EventArgs e)
        {
            int    kiTr   = 209;
            int    kiTg   = 224;
            int    kiTb   = 17;
            double kdLoss = 0.0;
            double kdBest = double.MaxValue;
            int    kiCnum = 0;
            Bitmap koBmp  = ( Bitmap )this.voOrig.Clone( );

            for (int m = 0; m < this.voCluster.Count; m++)
            {
                kdLoss = Math.Sqrt((( double )kiTr - this.voGmmnd.mu[m][0, 0]) * (( double )kiTr - this.voGmmnd.mu[m][0, 0]) +
                                   (( double )kiTg - this.voGmmnd.mu[m][0, 1]) * (( double )kiTg - this.voGmmnd.mu[m][0, 1]) +
                                   (( double )kiTb - this.voGmmnd.mu[m][0, 2]) * (( double )kiTb - this.voGmmnd.mu[m][0, 2]));
                if (kdLoss < kdBest)
                {
                    kdBest = kdLoss;
                    kiCnum = m;
                }
            }

            MyImageProc.DrawCluster(this.voPB, this.mClusterPoints( ), ref koBmp, 1, kiCnum);
        }