示例#1
0
        /// <summary>
        /// Update picture box images
        /// </summary>
        private void UpdateImages()
        {
            int fh = this.Size.Height;
            int fw = this.Size.Width;

            pictureBox_image1.Size = new System.Drawing.Size(fw / 2, (fh * 50) / 100);
            pictureBox_image2.Size = new System.Drawing.Size(fw / 2, (fh * 50) / 100);

            if (image1 != null)
            {
                display_image1          = CommonUtils.ImageUtils.Resize(image1, pictureBox_image1.Size);
                pictureBox_image1.Image = display_image1;
            }
            if (image2 != null)
            {
                display_image2          = CommonUtils.ImageUtils.Resize(image2, pictureBox_image2.Size);
                pictureBox_image2.Image = display_image2;
            }

            pictureBox_image1.Refresh();
            pictureBox_image2.Refresh();
            GroupBox_Similarity.Refresh();
        }
示例#2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Compare2ImagesForm()
        {
            InitializeComponent();
            AllowDrop      = true;
            this.AllowDrop = true;
            image_changed  = false;

            string text_dd = "Drag and drop an image in the box bellow";

            label_image1.Text = text_dd;
            label_image1.Refresh();
            label_image2.Text = text_dd;
            label_image2.Refresh();

            double similarity = 0.0;

            UpdateSimilarityLabel(this.label_AvgHash_similarity, similarity);
            UpdateSimilarityLabel(this.label_BlockHash_similarity, similarity);
            UpdateSimilarityLabel(this.label_DiffHash_similarity, similarity);
            UpdateSimilarityLabel(this.label_MD5Hash_similarity, similarity);
            UpdateSimilarityLabel(this.label_PHash_similarity, similarity);
            UpdateSimilarityLabel(this.label_HistogramHash_similarity, similarity);

            UpdateSimilarityLabel(this.label_DiffPixelsRgb_similarity, similarity);
            UpdateSimilarityLabel(this.label_DiffPixelsRgb_sorted_similarity, similarity);
            UpdateSimilarityLabel(this.label_DistPixelsRgb_similarity, similarity);
            UpdateSimilarityLabel(this.label_DistPixelsRgb_sorted_similarity, similarity);

            UpdateSimilarityLabel(this.label_RGBHistogram_similarity, similarity);
            UpdateSimilarityLabel(this.label_RGBHistogramAverage_similarity, similarity);

            UpdateSimilarityLabel(this.label_Feature_similarity, similarity);
            UpdateSimilarityLabel(this.labelDominantColors_similarity, similarity);

            GroupBox_Similarity.Refresh();
            CenterToScreen();
        }
示例#3
0
        /// <summary>
        ///  Update Image after Drap&Drop
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="devent"></param>
        private void PictureBoxDragDrop(object sender, DragEventArgs devent)
        {
            string filename = DroppedImageName(devent);

            try
            {
                if (sender.Equals(this.pictureBox_image1))
                {
                    devent.Effect = DragDropEffects.Copy;

                    image1_path = Path.GetFileName(filename);
                    if (image1_path.Length > 30)
                    {
                        image1_path = image1_path.Substring(0, 10) + ".." + image1_path.Substring(image1_path.Length - 10, 10);
                    }

                    image1 = Image.FromFile(@filename, true);

                    string fileinfo = String.Format("{1}x{2} {0}", image1_path, image1.Width, image1.Height);
                    label_image1.Text = fileinfo;
                    label_image1.Refresh();

                    display_image1          = CommonUtils.ImageUtils.Resize(image1, pictureBox_image1.Size);
                    pictureBox_image1.Image = display_image1;
                    pictureBox_image1.Refresh();

                    var display_small1 = CommonUtils.ImageUtils.Resize(pictureBox_image1.Image, pictureBox_small1_gray.Width, pictureBox_small1_gray.Height);
                    pictureBox_small1.Image = display_small1;
                    pictureBox_small1.Refresh();
                    pictureBox_small1_gray.Image = CommonUtils.ImageUtils.MakeGrayscaleFastest(display_small1);
                    pictureBox_small1_gray.Refresh();

                    label_message.Text = " ";
                    label_message.Refresh();
                }

                if (sender.Equals(this.pictureBox_image2))
                {
                    devent.Effect = DragDropEffects.Copy;

                    image2_path = Path.GetFileName(filename);
                    if (image2_path.Length > 30)
                    {
                        image2_path = image2_path.Substring(0, 10) + ".." + image2_path.Substring(image2_path.Length - 10, 10);
                    }

                    image2 = Image.FromFile(@filename, true);
                    string fileinfo = String.Format("{1}x{2} {0}", Path.GetFileName(image2_path), image2.Width, image2.Height);
                    label_image2.Text = fileinfo;
                    label_image2.Refresh();

                    display_image2          = CommonUtils.ImageUtils.Resize(image2, pictureBox_image2.Size);
                    pictureBox_image2.Image = display_image2;
                    pictureBox_image2.Refresh();

                    var display_small2 = CommonUtils.ImageUtils.Resize(pictureBox_image2.Image, pictureBox_small2_gray.Width, pictureBox_small2_gray.Height);
                    pictureBox_small2.Image = display_small2;
                    pictureBox_small2.Refresh();
                    pictureBox_small2_gray.Image = CommonUtils.ImageUtils.MakeGrayscaleFastest(display_small2);
                    pictureBox_small2_gray.Refresh();

                    label_message.Text = " ";
                    label_message.Refresh();
                }

                image_changed = true;
                ImageSimilarityStats();
                GroupBox_Similarity.Refresh();
            }
            catch (System.IO.FileNotFoundException)
            {
                string msg = "could not read the image.";
                label_message.Text = msg;
                label_message.Refresh();
            }
            catch (System.OutOfMemoryException)
            {
#if DEBUG
                string msg     = "The file does not have a valid image format (BMP ,GIF , JPEG, PNG or TIFF ).";
                string caption = "Error: wrong format";
                MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
#endif
            }
            catch (System.ArgumentException e)
            {
                var    error = e.ToString();
                string name  = filename;
                if (filename.Length > 30)
                {
                    name = filename.Substring(0, 10) + ".." + filename.Substring(filename.Length - 10, 10);
                }
                string msg = "could not read file " + name;
#if DEBUG
                msg = "could not read file :" + error;
                string caption = String.Empty;
                MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
#endif
                label_message.Text = msg;
                label_message.Refresh();
            }
        }