private void btnFolder_Click(object sender, EventArgs e)
        {
            lblStatus.Text = "Status: Start";
            folderBrowserDialog1.SelectedPath = folderPath;
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                filePaths.Clear();
                CheckFileNumber();

                int fileNumber = filePaths.Count;

                if (fileNumber > 0)
                {
                    lblStatus.Text = "Status: On-Going...";
                    Directory.CreateDirectory(folderPath + "Result\\");
                    excel = new DataExcel();

                    for (int j = 0; j < fileNumber; j++)
                    {
                        string fileName = Path.GetFileNameWithoutExtension(filePaths[j]);
                        //Directory.CreateDirectory(folderPath + "Result\\" + fileName + "\\");

                        imageMain       = new Image <Bgr, byte>(filePaths[j]);
                        imgMain.Image   = imageMain;
                        image_Main_Copy = imageMain.Clone();
                        Ini();
                        //IntROIPosition();
                        DrawROI();
                        CalUniformity(fileName, j + 1);

                        SaveROI(folderPath + "Result\\" + fileName);
                        lblPath.Text = filePaths[j];
                    }

                    excel.Save(folderPath + "rawData");
                    excel.Close();

                    lblStatus.Text = "Finish All Pictures!!!";
                }
                else
                {
                    lblStatus.Text = "No New Picture";
                }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            lblStatus.Text = "Update ROI";
            string imgPath = lblPath.Text;

            string[] temp     = imgPath.Split('\\');
            string   path     = string.Empty;
            string   fileName = string.Empty;

            for (int i = 0; i < temp.Length - 1; i++)
            {
                path += temp[i] + "\\";
            }
            fileName = Path.GetFileNameWithoutExtension(temp[temp.Length - 1]);

            excel = new DataExcel();
            CalUniformity(fileName, 1);
            SaveROI(path + "\\Result\\" + fileName);

            excel.Save(folderPath + "rawData");
            excel.Close();

            lblStatus.Text = "Finish Update";
        }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            lblStatus.Text = "Status: Start";
            string imgPath;

            filePaths.Clear();

            openFileDialog1.Filter      = "Image files (*.jpg;*.png)|*.jpg;*.png|All files (*.*)|*.*";
            openFileDialog1.Multiselect = false;
            openFileDialog1.Title       = "Select a picture";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                lblStatus.Text = "Status: On-Going...";
                folderPath     = string.Empty;
                imageMain      = new Image <Bgr, byte>(openFileDialog1.FileName);
                imgPath        = Path.GetFullPath(openFileDialog1.FileName);
                lblPath.Text   = imgPath;

                string[] temp = imgPath.Split('\\');
                for (int i = 0; i < temp.Length - 1; i++)
                {
                    folderPath += temp[i] + "\\";
                }
                Directory.CreateDirectory(folderPath + "Result\\");
                string fileName = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);

                excel = new DataExcel();

                imgMain.Image   = imageMain;
                image_Main_Copy = imageMain.Clone();
                Ini();
                IntROIPosition();
                DrawROI();
                CalUniformity(fileName, 1);
                SaveROI(folderPath + "Result\\" + fileName);

                excel.Save(folderPath + "rawData");
                excel.Close();

                // Enable Button
                btnFolder.Enabled   = true;
                btnUpdate.Enabled   = true;
                btnIncrease.Enabled = true;
                btnDecrease.Enabled = true;

                btnUp.Enabled    = true;
                btnDown.Enabled  = true;
                btnRight.Enabled = true;
                btnLeft.Enabled  = true;

                btnCenterUp.Enabled    = true;
                btnCenterDown.Enabled  = true;
                btnCenterLeft.Enabled  = true;
                btnCenterRight.Enabled = true;

                lblStatus.Text = "Finish one Picture";
            }
            else
            {
                lblStatus.Text = "No New Picture";
            }
        }