コード例 #1
0
ファイル: NR_algorithm.cs プロジェクト: veason/ImageSorting
        public static double NR_method(string algorithm, int[, ,] image, int height, int width)
        {
            switch (algorithm)
            {
            case "Tenengrad":
            {
                return(NR_algorithm.Tenengrad(image, height, width));
            }

            case "Brenner":
            {
                return(NR_algorithm.Brenner(image, height, width));
            }

            default:
            {
                if (SettingInfo.dllHelper.NR_methods.ContainsKey(algorithm))
                {
                    object     reflectInstance = Activator.CreateInstance(SettingInfo.dllHelper.NR_methods[algorithm]);
                    MethodInfo methodInfo      = SettingInfo.dllHelper.NR_methods[algorithm].GetMethod("NR_method",
                                                                                                       new Type[] { typeof(int[, , ]), typeof(int), typeof(int) });
                    return((double)methodInfo.Invoke(reflectInstance,
                                                     new object[] { image, height, width }));
                }
                return(-1);
            }
            }
        }
コード例 #2
0
        private void CompareForm_Load(object sender, EventArgs e)
        {
            this.WindowState        = FormWindowState.Maximized;
            this.FormBorderStyle    = FormBorderStyle.FixedSingle;
            compare_image1.Width    = compare_image1.Height = (int)(this.Width * image_size_rate);
            compare_image2.Width    = compare_image2.Height = (int)(this.Width * image_size_rate);
            compare_image1.Location = new Point((int)(this.Width * 0.015), (int)(this.Height * 0.02));
            compare_image2.Location = new Point((int)(this.Width * 0.515), (int)(this.Height * 0.02));
            confirm.Location        = new Point((int)(this.Width * 0.475), (int)(this.Height * 0.86));

            double result1 = NR_algorithm.NR_method(
                SettingInfo.imageCompare_NRmethod,
                MainInfo.picInfo[MainInfo.path_name[id1]].rgb,
                MainInfo.picInfo[MainInfo.path_name[id1]].height,
                MainInfo.picInfo[MainInfo.path_name[id1]].width);
            double result2 = NR_algorithm.NR_method(
                SettingInfo.imageCompare_NRmethod,
                MainInfo.picInfo[MainInfo.path_name[id2]].rgb,
                MainInfo.picInfo[MainInfo.path_name[id2]].height,
                MainInfo.picInfo[MainInfo.path_name[id2]].width);
            int          score1 = NR_algorithm.NR_grade(SettingInfo.imageCompare_NRmethod, result1);
            int          score2 = NR_algorithm.NR_grade(SettingInfo.imageCompare_NRmethod, result2);
            picturePanel p1     = new picturePanel();
            picturePanel p2     = new picturePanel();

            compare_image1.Controls.Add(p1);
            compare_image2.Controls.Add(p2);
            p1.init(MainInfo.picInfo[MainInfo.path_name[id1]].image, "得分:" +  score1.ToString());
            p2.init(MainInfo.picInfo[MainInfo.path_name[id2]].image, "得分:"   +  score2.ToString());

            p1.image_name.Height = 33;
            p2.image_name.Height = 33;
            p1.image_name.Font   = new Font("微软雅黑", 18);
            p2.image_name.Font   = new Font("微软雅黑", 18);
        }
コード例 #3
0
ファイル: SortingResult.cs プロジェクト: veason/ImageSorting
        public SortingResult()
        {
            InitializeComponent();
            _path  = null;
            picNum = 0;
            for (int i = 0; i < MainInfo.tot; i++)
            {
                if (MainInfo.selected[i])
                {
                    picNum++;
                }
            }
            progress = 0;
            int    id             = 0;
            Thread progressThread = new Thread(progress_thread);

            progressThread.IsBackground = true;
            progressThread.Start();
            originArray = new SortObject[picNum];
            sortedArray = new SortObject[picNum];
            for (int i = 0; i < MainInfo.tot; i++)
            {
                if (MainInfo.selected[i])
                {
                    double result = NR_algorithm.NR_method(
                        SettingInfo.imageSort_NRmethod,
                        MainInfo.picInfo[MainInfo.path_name[i]].rgb,
                        MainInfo.picInfo[MainInfo.path_name[i]].height,
                        MainInfo.picInfo[MainInfo.path_name[i]].width);
                    MainInfo.picInfo[MainInfo.path_name[i]].grade_none = NR_algorithm.NR_grade(SettingInfo.imageSort_NRmethod, result);
                    originArray[id]   = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_none, MainInfo.path_name[i], MainInfo.name[i]);
                    sortedArray[id++] = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_none, MainInfo.path_name[i], MainInfo.name[i]);
                }
                progress = 1000 * id / picNum;
            }
            Array.Sort(sortedArray, new sortObjectComparer()); //图片排序调用
            origin_e1 = new EventHandler(origin_item_double_click);
            origin_e2 = new EventHandler(origin_pictureBox_double_click);
            origin_e3 = new EventHandler(origin_label_double_click);
            sorted_e1 = new EventHandler(sorted_item_double_click);
            sorted_e2 = new EventHandler(sorted_pictureBox_double_click);
            sorted_e3 = new EventHandler(sorted_label_double_click);
        }
コード例 #4
0
        private void confirm_Click(object sender, EventArgs e)
        {
            Dispose();
            int tot = 0;

            for (int i = 0; i < MainInfo.tot; i++)
            {
                if (MainInfo.selected[i])
                {
                    tot++;
                }
            }
            int index = 0;

            if (ratioButton.Checked)
            {
                SortObject[] sortedArray = new SortObject[tot];
                for (int i = 0; i < MainInfo.tot; i++)
                {
                    if (MainInfo.selected[i])
                    {
                        double result = NR_algorithm.NR_method(
                            SettingInfo.imageClear_NRmethod,
                            MainInfo.picInfo[MainInfo.path_name[i]].rgb,
                            MainInfo.picInfo[MainInfo.path_name[i]].height,
                            MainInfo.picInfo[MainInfo.path_name[i]].width);
                        MainInfo.picInfo[MainInfo.path_name[i]].grade_none = NR_algorithm.NR_grade(SettingInfo.imageClear_NRmethod, result);
                        sortedArray[index++] = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_none, MainInfo.path_name[i], MainInfo.name[i]);
                    }
                }

                Array.Sort(sortedArray, new sortObjectComparer());
                DeleteComfirm imageDeleteComfirmForm = new DeleteComfirm(clearingRatioBar.Value, mf, sortedArray);
                imageDeleteComfirmForm.Show();
            }
            else
            {
                SortObject[] sortedArrayTemp = new SortObject[tot];

                for (int i = 0; i < MainInfo.tot; i++)
                {
                    if (MainInfo.selected[i])
                    {
                        double result = NR_algorithm.NR_method(SettingInfo.imageClear_NRmethod,
                                                               MainInfo.picInfo[MainInfo.path_name[i]].rgb,
                                                               MainInfo.picInfo[MainInfo.path_name[i]].height,
                                                               MainInfo.picInfo[MainInfo.path_name[i]].width);
                        MainInfo.picInfo[MainInfo.path_name[i]].grade_none = NR_algorithm.NR_grade(SettingInfo.imageClear_NRmethod, result);
                        if (MainInfo.picInfo[MainInfo.path_name[i]].grade_none <= threadsoldBar.Value)
                        {
                            sortedArrayTemp[index++] = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_none, MainInfo.path_name[i], MainInfo.name[i]);
                        }
                    }
                }
                SortObject[] sortedArray = new SortObject[index];
                for (int i = 0; i < index; i++)
                {
                    sortedArray[i] = sortedArrayTemp[i];
                }

                Array.Sort(sortedArray, new sortObjectComparer());
                DeleteComfirm imageDeleteComfirmForm = new DeleteComfirm(100, mf, sortedArray);
                imageDeleteComfirmForm.Show();
            }
        }