Esempio n. 1
0
        public static int FR_grade(string algorithm, double result)
        {
            switch (algorithm)
            {
            case "PSNR":
            {
                return(FR_algorithm.PSNR_grade(result));
            }

            case "LBP":
            {
                return(FR_algorithm.LBP_grade(result));
            }

            default:
            {
                if (SettingInfo.dllHelper.FR_methods.ContainsKey(algorithm))
                {
                    object     reflectInstance = Activator.CreateInstance(SettingInfo.dllHelper.FR_methods[algorithm]);
                    MethodInfo methodInfo      = SettingInfo.dllHelper.FR_methods[algorithm].GetMethod("FR_grade",
                                                                                                       new Type[] { typeof(double) });
                    return((int)methodInfo.Invoke(reflectInstance,
                                                  new object[] { result }));
                }
                return(-1);
            }
            }
        }
Esempio n. 2
0
        public static double FR_method(string algorithm, int[, ,] image1, int[, ,] image2, int height, int width)
        {
            switch (algorithm)
            {
            case "PSNR":
            {
                return(FR_algorithm.PSNR(image1, image2, height, width));
            }

            case "LBP":
            {
                return(FR_algorithm.LBP(image1, image2, height, width));
            }

            default:
            {
                if (SettingInfo.dllHelper.FR_methods.ContainsKey(algorithm))
                {
                    object     reflectInstance = Activator.CreateInstance(SettingInfo.dllHelper.FR_methods[algorithm]);
                    MethodInfo methodInfo      = SettingInfo.dllHelper.FR_methods[algorithm].GetMethod("FR_method",
                                                                                                       new Type[] { typeof(int[, , ]), typeof(int[, , ]), typeof(int), typeof(int) });
                    return((double)methodInfo.Invoke(reflectInstance,
                                                     new object[] { image1, image2, height, width }));
                }
                return(-1);
            }
            }
        }
Esempio n. 3
0
        public SortingResult(string _path)
        {
            InitializeComponent();
            this._path = _path;
            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])
                {
                    MainInfo.picInfo[MainInfo.path_name[i]].grade_full = FR_algorithm.FR_method(
                        SettingInfo.imageSort_FRmethod,
                        MainInfo.picInfo[MainInfo.path_name[i]].rgb,
                        MainInfo.picInfo[_path].rgb,
                        MainInfo.picInfo[_path].height,
                        MainInfo.picInfo[_path].width);
                    originArray[id]   = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_full, MainInfo.path_name[i], MainInfo.name[i]);
                    sortedArray[id++] = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_full, 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);
        }
Esempio n. 4
0
        private void radioButton1_Click(object sender, EventArgs e)
        {
            radioButton1.Checked = true;
            radioButton2.Checked = false;
            temp_image           = new Bitmap(MainInfo.picInfo[_path].compress(100 - (Int64)rate_bar1.Value, imageformat[format_selection.Text]));
            ((picturePanel)(compressed_image.Controls[0])).init(temp_image, "预览".ToString());
            picturePanel tempP = (picturePanel)(compressed_image.Controls[0]);

            tempP.image_name.Font     = new Font("微软雅黑", 17);
            tempP.image_name.Height   = 32;
            tempP.image_name.Dock     = DockStyle.None;
            tempP.image_name.Location = new Point((tempP.image.Location.X), tempP.image.Location.Y + tempP.image.Height + 20);

            Pic    pic    = new Pic(temp_image);
            double result = FR_algorithm.FR_method(SettingInfo.imageCompress_FRmethod, MainInfo.picInfo[_path].rgb, pic.rgb, pic.height, pic.width);
            int    grade  = FR_algorithm.FR_grade(SettingInfo.imageCompress_FRmethod, result);

            rate_bar2.Value      = grade;
            rate2.Text           = rate_bar2.Value.ToString();
            algorithm_value.Text = "(" + SettingInfo.imageCompress_FRmethod + "值:" + result.ToString("f4") + ")";
        }
Esempio n. 5
0
        private void rate_bar2_Scroll(object sender, EventArgs e)
        {
            rate2.Text = rate_bar2.Value.ToString();
            double result = 0;
            int    grade  = 0;

            if (radioButton2.Checked)
            {
                int l = 0, r = 100, mid;
                while (l != r)
                {
                    mid        = (l + r) >> 1;
                    temp_image = new Bitmap(MainInfo.picInfo[_path].compress((Int64)(mid + 1), imageformat[format_selection.Text]));
                    Pic pic = new Pic(temp_image);
                    result = FR_algorithm.FR_method(SettingInfo.imageCompress_FRmethod, MainInfo.picInfo[_path].rgb, pic.rgb, pic.height, pic.width);
                    grade  = FR_algorithm.FR_grade(SettingInfo.imageCompress_FRmethod, result);
                    if (grade > rate_bar2.Value)
                    {
                        r = mid;
                    }
                    else
                    {
                        l = mid + 1;
                    }
                }
                ((picturePanel)(compressed_image.Controls[0])).init(temp_image, "预览".ToString());
                picturePanel tempP = (picturePanel)(compressed_image.Controls[0]);
                tempP.image_name.Font     = new Font("微软雅黑", 17);
                tempP.image_name.Height   = 32;
                tempP.image_name.Dock     = DockStyle.None;
                tempP.image_name.Location = new Point((tempP.image.Location.X), tempP.image.Location.Y + tempP.image.Height + 20);

                rate_bar1.Value      = 100 - l;
                rate1.Text           = rate_bar1.Value.ToString();
                algorithm_value.Text = "(" + SettingInfo.imageCompress_FRmethod + "值:" + result.ToString("f4") + ")";
            }
        }
Esempio n. 6
0
        private void compressForm_none_Load(object sender, EventArgs e)
        {
            this.WindowState               = FormWindowState.Maximized;
            this.FormBorderStyle           = FormBorderStyle.FixedSingle;
            format_selection.DropDownStyle = ComboBoxStyle.DropDownList;
            uncompressed_image.Width       = uncompressed_image.Height = compressed_image.Width = compressed_image.Height = (int)(this.Height * 0.65);
            uncompressed_image.Location    = new Point((int)(this.Width * 0.1), (int)(this.Height * 0.02));
            compressed_image.Location      = new Point((int)(this.Width * 0.55), (int)(this.Height * 0.02));
            image_format.Location          = new Point((int)(this.Width * 0.352), (int)(this.Height * 0.7));
            format_selection.Location      = new Point((int)(this.Width * 0.46), (int)(this.Height * 0.7));
            hint1.Location           = new Point((int)(image_format.Location.X + image_format.Width - hint1.Width), (int)(this.Height * 0.76));
            hint2.Location           = new Point((int)(image_format.Location.X + image_format.Width - hint2.Width), (int)(this.Height * 0.82));
            rate_bar1.Location       = new Point((int)(format_selection.Location.X + (format_selection.Width - rate_bar1.Width) / 2), (int)(this.Height * 0.76));
            rate_bar2.Location       = new Point((int)(format_selection.Location.X + (format_selection.Width - rate_bar2.Width) / 2), (int)(this.Height * 0.82));
            rate1.Location           = new Point((int)(this.Width * 0.59), (int)(this.Height * 0.76));
            rate2.Location           = new Point((int)(this.Width * 0.59), (int)(this.Height * 0.82));
            algorithm_value.Location = new Point((int)(this.Width * 0.65), (int)(this.Height * 0.82));
            radioButton1.Location    = new Point((int)(this.Width * 0.625), (int)(this.Height * 0.769));
            radioButton2.Location    = new Point((int)(this.Width * 0.625), (int)(this.Height * 0.829));
            save.Location            = new Point((int)(this.Width * 0.42), (int)(this.Height * 0.89));
            cancel.Location          = new Point((int)(this.Width * 0.55), (int)(this.Height * 0.89));

            if (SettingInfo.save_path == "default")
            {
                save_path = "default" + "\\" + _name + "(compressed)." + format_selection.Text;
                if (Directory.Exists("default") == false)
                {
                    Directory.CreateDirectory("default");
                }
            }
            else
            {
                save_path = SettingInfo.save_path + "\\" + _name + "(compressed)." + format_selection.Text;
            }

            p1 = new picturePanel();
            uncompressed_image.Controls.Add(p1);
            p1.init(MainInfo.picInfo[_path].image, "原图".ToString());
            p1.image_name.Font     = new Font("微软雅黑", 17);
            p1.image_name.Height   = 32;
            p1.image_name.Location = new Point((p1.image.Location.X), (p1.image.Location.Y + 20 + p1.image.Height));
            p1.image_name.Dock     = DockStyle.None;

            p2 = new picturePanel();
            compressed_image.Controls.Add(p2);
            p2.image_name.Font     = new Font("微软雅黑", 17);
            p2.image_name.Height   = 32;
            p2.image_name.Location = new Point((p2.image.Location.X), (p2.image.Location.Y + 20 + p2.image.Height));
            p2.image_name.Dock     = DockStyle.None;
            temp_image             = new Bitmap(MainInfo.picInfo[_path].compress(50, imageformat[format_selection.Text]));
            ((picturePanel)(compressed_image.Controls[0])).init(temp_image, "预览".ToString());
            picturePanel tempP = (picturePanel)(compressed_image.Controls[0]);

            tempP.image_name.Font     = new Font("微软雅黑", 17);
            tempP.image_name.Height   = 32;
            tempP.image_name.Dock     = DockStyle.None;
            tempP.image_name.Location = new Point((tempP.image.Location.X), tempP.image.Location.Y + tempP.image.Height + 20);

            temp_image = new Bitmap(MainInfo.picInfo[_path].compress(100 - (Int64)rate_bar1.Value, imageformat[format_selection.Text]));
            ((picturePanel)(compressed_image.Controls[0])).init(temp_image, "预览".ToString());
            tempP = (picturePanel)(compressed_image.Controls[0]);
            tempP.image_name.Font     = new Font("微软雅黑", 17);
            tempP.image_name.Height   = 32;
            tempP.image_name.Dock     = DockStyle.None;
            tempP.image_name.Location = new Point((tempP.image.Location.X), tempP.image.Location.Y + tempP.image.Height + 20);
            Pic    pic    = new Pic(temp_image);
            double result = FR_algorithm.FR_method(SettingInfo.imageCompress_FRmethod, MainInfo.picInfo[_path].rgb, pic.rgb, pic.height, pic.width);
            int    grade  = FR_algorithm.FR_grade(SettingInfo.imageCompress_FRmethod, result);

            rate_bar2.Value      = grade;
            rate2.Text           = rate_bar2.Value.ToString();
            algorithm_value.Text = "(" + SettingInfo.imageCompress_FRmethod + "值:" + result.ToString("f4") + ")";
        }
Esempio n. 7
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 = FR_algorithm.FR_method(SettingInfo.imageClear_FRmethod,
                                                               MainInfo.picInfo[MainInfo.path_name[i]].rgb,
                                                               MainInfo.picInfo[referenceImage].rgb,
                                                               MainInfo.picInfo[referenceImage].height,
                                                               MainInfo.picInfo[referenceImage].width);
                        MainInfo.picInfo[MainInfo.path_name[i]].grade_full = FR_algorithm.FR_grade(SettingInfo.imageClear_FRmethod, result);
                        sortedArray[index++] = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_full, 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 = FR_algorithm.FR_method(SettingInfo.imageClear_FRmethod,
                                                               MainInfo.picInfo[MainInfo.path_name[i]].rgb,
                                                               MainInfo.picInfo[referenceImage].rgb,
                                                               MainInfo.picInfo[referenceImage].height,
                                                               MainInfo.picInfo[referenceImage].width);
                        MainInfo.picInfo[MainInfo.path_name[i]].grade_full = FR_algorithm.FR_grade(SettingInfo.imageClear_FRmethod, result);
                        if (MainInfo.picInfo[MainInfo.path_name[i]].grade_full <= threadsoldBar.Value)
                        {
                            sortedArrayTemp[index++] = new SortObject(MainInfo.picInfo[MainInfo.path_name[i]].grade_full, MainInfo.path_name[i], MainInfo.name[i]);
                        }
                    }
                }
                MainForm.previous_pic = referenceImage;
                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();
            }
        }