• 大小: 46KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: C#
  • 标签:

资源简介

C# 比较图片相似度技术,能达到100%.

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ThePictureContrast
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Graphics Graphics1 = null;
        Graphics Graphics2 = null;
        private void pictureBox1_Click(object sender EventArgs e)
        {
            OpenFileDialog fDilag = new OpenFileDialog();
            fDilag.Filter = “All files (*.jpg)|*.jpg“;
            fDilag.FilterIndex = 2;
            fDilag.RestoreDirectory = true;
            fDilag.ShowDialog();
            string filename = fDilag.FileName;
            if (filename != ““)
            {
                SimilarPhoto sp = new SimilarPhoto(filename);
                mes1 = sp.GetHash();
                pictureBox1.Image = sp.ReduceSize();
            }
        }

        private void pictureBox2_Click(object sender EventArgs e)
        {
            OpenFileDialog fDilag = new OpenFileDialog();
            fDilag.Filter = “All files (*.jpg)|*.jpg“;
            fDilag.FilterIndex = 2;
            fDilag.RestoreDirectory = true;
            fDilag.ShowDialog();
            string filename = fDilag.FileName;
            if (filename != ““)
            {
                SimilarPhoto sp = new SimilarPhoto(filename);
                mes2 = sp.GetHash();
                pictureBox2.Image = sp.ReduceSize();
            }
        }
        String mes1 = ““;
        String mes2 = ““;
        double num = 0;
        private void button1_Click(object sender EventArgs e)
        {
            ComparisonPicture();
        }

        private void ComparisonPicture()
        {
            double xiangshidu = 0;
            num = 0;
            if (mes1.Length == mes2.Length)
            {
                for (int i = 0; i < mes2.Length; i++)
                {
                    if (mes1[i] != mes2[i])
                    {
                        num = num + 1;
                    }
                }
            }

            if (num == 0)
            {
                MessageBox.Show(“相似“);
                xiangshidu = 100;
            }
            if (num > 0)
            {
                double nu = num / mes2.Length;
                xiangshidu = (mes2.Length - num) / mes2.Length;
                if (nu < 0.0069)
                {
                    MessageBox.Show(“相似“);
                }
                else
                {
                    MessageBox.Show(“不相似“);
                }

            }
            label4.Text = xiangshidu.ToString();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      12288  2014-06-24 17:24  ThePictureContrast\bin\Debug\ThePictureContrast.exe

     文件      34304  2014-06-24 17:24  ThePictureContrast\bin\Debug\ThePictureContrast.pdb

     文件      11600  2014-06-24 17:35  ThePictureContrast\bin\Debug\ThePictureContrast.vshost.exe

     文件        490  2013-06-18 20:28  ThePictureContrast\bin\Debug\ThePictureContrast.vshost.exe.manifest

     文件       2828  2014-06-24 17:24  ThePictureContrast\Form1.cs

     文件       5744  2014-06-24 17:24  ThePictureContrast\Form1.Designer.cs

     文件       5817  2014-06-24 17:24  ThePictureContrast\Form1.resx

     文件       5420  2014-06-23 16:27  ThePictureContrast\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6341  2014-06-24 17:24  ThePictureContrast\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        802  2014-06-24 17:35  ThePictureContrast\obj\x86\Debug\ThePictureContrast.csproj.FileListAbsolute.txt

     文件        975  2014-06-24 17:24  ThePictureContrast\obj\x86\Debug\ThePictureContrast.csproj.GenerateResource.Cache

     文件       9174  2014-06-23 16:31  ThePictureContrast\obj\x86\Debug\ThePictureContrast.csprojResolveAssemblyReference.cache

     文件      12288  2014-06-24 17:24  ThePictureContrast\obj\x86\Debug\ThePictureContrast.exe

     文件        180  2014-06-24 17:24  ThePictureContrast\obj\x86\Debug\ThePictureContrast.Form1.resources

     文件      34304  2014-06-24 17:24  ThePictureContrast\obj\x86\Debug\ThePictureContrast.pdb

     文件        180  2014-06-23 16:09  ThePictureContrast\obj\x86\Debug\ThePictureContrast.Properties.Resources.resources

     文件        499  2014-06-23 15:59  ThePictureContrast\Program.cs

     文件       1368  2014-06-23 15:59  ThePictureContrast\Properties\AssemblyInfo.cs

     文件       2888  2014-06-23 15:59  ThePictureContrast\Properties\Resources.Designer.cs

     文件       5612  2014-06-23 15:59  ThePictureContrast\Properties\Resources.resx

     文件       1105  2014-06-23 15:59  ThePictureContrast\Properties\Settings.Designer.cs

     文件        249  2014-06-23 15:59  ThePictureContrast\Properties\Settings.settings

     文件       2798  2014-06-23 17:02  ThePictureContrast\SimilarPhoto.cs

     文件       3738  2014-06-23 16:09  ThePictureContrast\ThePictureContrast.csproj

     文件        896  2014-06-23 15:59  ThePictureContrast.sln

     目录          0  2014-06-23 15:59  ThePictureContrast\obj\x86\Debug\TempPE

     目录          0  2014-06-24 17:24  ThePictureContrast\obj\x86\Debug

     目录          0  2014-06-23 16:09  ThePictureContrast\bin\Debug

     目录          0  2014-06-23 15:59  ThePictureContrast\obj\x86

     目录          0  2014-06-23 15:59  ThePictureContrast\bin

............此处省略6个文件信息

评论

共有 条评论

相关资源