private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            int index = 0;
            string path = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Output.txt");
            StreamWriter file = new StreamWriter(@path);

            KNearestNeighbour knnClassifier = new KNearestNeighbour(10, Main.trainingImagesFeatures, Main.trainingLabels);

            this.confusionMatrix = new int[10, 10];

            var watch = Stopwatch.StartNew();

            if (ClassifierType == "KNN")
            {
                while (index != NumberOfImages)
                {
                    int classIndex = knnClassifier.classify(K, Mode.testImagesFeatures[index]);

                    this.confusionMatrix[Mode.testLabels[index], classIndex]++;

                    string[] output = { index.ToString(), Mode.testLabels[index].ToString(), classIndex.ToString() };

                    this.dataGridView1.Rows.Add(output);

                    string outputFile = "Image# " + index.ToString() + "\t Predection: "
                        + classIndex.ToString() + "\t Label: " + Mode.testLabels[index] + "\n";

                    file.WriteLine(outputFile);

                    index++;
                }

                watch.Stop();
                file.WriteLine(watch.ElapsedMilliseconds.ToString());

                Process proc = Process.GetCurrentProcess();

                file.WriteLine((proc.PrivateMemorySize64 / 1024).ToString());
            }

            else if (ClassifierType == "KNN Modified")
            {
                while (index != NumberOfImages)
                {
                    int classIndex = knnClassifier.classifyModified(Mode.testImagesFeatures[index]);

                    this.confusionMatrix[Mode.testLabels[index], classIndex]++;

                    string[] output = { index.ToString(), Mode.testLabels[index].ToString(), classIndex.ToString() };

                    this.dataGridView1.Rows.Add(output);

                    string outputFile = "Image# " + index.ToString() + "\t Predection: "
                        + classIndex.ToString() + "\t Label: " + Mode.testLabels[index] + "\n";

                    file.WriteLine(outputFile);

                    index++;
                }

                watch.Stop();
                file.WriteLine(watch.ElapsedMilliseconds.ToString());

                Process proc = Process.GetCurrentProcess();

                file.WriteLine((proc.PrivateMemorySize64 / 1024).ToString());
            }

            file.Close();

            ConfusionMatrixForm cmf = new ConfusionMatrixForm();
            cmf.Show();

            cmf.setConfusionMatrix(this.confusionMatrix, watch.ElapsedMilliseconds.ToString());
        }
        private void classifyBtn_Click(object sender, EventArgs e)
        {
            Bitmap currentImage = new Bitmap(pictureBox1.Image);

            if (ClassifierType == "KNN")
            {
                KNearestNeighbour knnClassifier = new KNearestNeighbour(10, Main.trainingImagesFeatures, Main.trainingLabels);

                pictureBox2.Image = pictureBox1.Image;
                Bitmap drawnImage = new Bitmap(scaledImage((Bitmap)pictureBox1.Image));
                pictureBox2.Image = drawnImage;
                //byte[] imageFeatures = bitmapToBuffer(drawnImage);

            //                int classIndex = knnClassifier.classifySorting(K, imageFeatures);

              //              MessageBox.Show(classIndex.ToString());

            }
        }