• 大小: 26.44MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-27
  • 语言: C#
  • 标签: opencv  OpenCvSharp  

资源简介

c# OpenCvSharp 图片相似度比较,四种方法对比,SSIM,PSNR,灰度直方图比较,RGB三通道全彩直方图比较,亲测,效果不错。

资源截图

代码片段和文件信息

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

namespace PictureCompare
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {

        }

        private void button1_Click_1(object sender EventArgs e)
        {
            richTextBox1.Clear();
            string picTest1 = textBox1.Text;
            string picTest2 = textBox2.Text;
            string similar = OpenCV.CompareHistColor(picTest1 picTest2);
            if (similar==““)
            {
                return;
            }
            double similar1 = OpenCV.CompareHistGray(picTest1 picTest2);
            double similar2 = OpenCV.Compute_PSNR(picTest1 picTest2);
            double[] similar3 = OpenCV.Compute_SSIM(picTest1 picTest2);
            richTextBox1.AppendText(“全彩:\r\n“);
            richTextBox1.AppendText(similar);
            richTextBox1.AppendText(“\r\n灰度:\r\n“);
            richTextBox1.AppendText(similar1 + “\r\n“);
            richTextBox1.AppendText(“\r\nPSNR:\r\n“);
            richTextBox1.AppendText(similar2 + “dB\r\n“);
            richTextBox1.AppendText(“\r\nSSIM:\r\n“);
            richTextBox1.AppendText(similar3[0]+“ “+ similar3[1]+“ “+ similar3[2] + “\r\n“);
        }

        private void button2_Click(object sender EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string FileBasicName = System.IO.Path.GetExtension(openFileDialog1.FileName);
                if (FileBasicName.ToLower() == “.png“ || FileBasicName.ToLower() == “.jpg“ || FileBasicName.ToLower() == “.jpeg“ || FileBasicName.ToLower() == “.gif“ || FileBasicName.ToLower() == “.bmp“)
                {

                    textBox1.Text = System.IO.Path.GetFullPath(openFileDialog1.FileName);
                    openFileDialog1.Dispose();
                }
                else
                {
                    textBox1.Text = “请上传正确格式的图片!“;
                }
            }
        }

        private void button3_Click(object sender EventArgs e)
        {
            if (openFileDialog2.ShowDialog() == DialogResult.OK)
            {
                string FileBasicName = System.IO.Path.GetExtension(openFileDialog1.FileName);
                if (FileBasicName.ToLower() == “.png“ || FileBasicName.ToLower() == “.jpg“ || FileBasicName.ToLower() == “.jpeg“ || FileBasicName.ToLower() == “.gif“ || FileBasicName.ToLower() == “.bmp“)
                {

                    textBox2.Text = System.IO.Path.GetFullPath(openFileDialog2.FileName);
                    openFileDialog1.Dispose();
                }
                else
                {
                    textBox2.Text = “请上传正确格式的图片!“;
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-06-28 15:30  ComparePicture\
     目录           0  2020-06-28 15:30  ComparePicture\.vs\
     目录           0  2020-06-28 15:30  ComparePicture\.vs\Compare\
     目录           0  2020-06-28 15:30  ComparePicture\.vs\Compare\v14\
     文件      553984  2019-06-24 10:52  ComparePicture\.vs\Compare\v14\.suo
     目录           0  2020-06-28 15:30  ComparePicture\.vs\Compare\v15\
     文件      542720  2020-06-28 15:29  ComparePicture\.vs\Compare\v15\.suo
     目录           0  2020-06-28 15:30  ComparePicture\.vs\Compare\v15\Server\
     目录           0  2020-06-28 15:30  ComparePicture\.vs\Compare\v15\Server\sqlite3\
     文件           0  2020-06-28 15:21  ComparePicture\.vs\Compare\v15\Server\sqlite3\db.lock
     文件        4096  2020-06-28 15:21  ComparePicture\.vs\Compare\v15\Server\sqlite3\storage.ide
     文件       32768  2020-06-28 15:21  ComparePicture\.vs\Compare\v15\Server\sqlite3\storage.ide-shm
     文件     1071232  2020-06-28 15:28  ComparePicture\.vs\Compare\v15\Server\sqlite3\storage.ide-wal
     目录           0  2020-06-28 15:30  ComparePicture\.vs\config\
     文件       83412  2019-04-15 10:06  ComparePicture\.vs\config\applicationhost.config
     文件        1009  2019-06-24 10:51  ComparePicture\Compare.sln
     目录           0  2020-06-28 15:30  ComparePicture\PictureCompare\
     文件        6921  2020-06-28 15:27  ComparePicture\PictureCompare\Form1.Designer.cs
     文件        3103  2020-06-28 15:27  ComparePicture\PictureCompare\Form1.cs
     文件        6224  2020-06-28 15:27  ComparePicture\PictureCompare\Form1.resx
     文件        8779  2019-06-24 10:40  ComparePicture\PictureCompare\OpenCV.cs
     文件        4342  2019-06-22 08:57  ComparePicture\PictureCompare\PictureCompare.csproj
     文件         475  2019-06-22 08:57  ComparePicture\PictureCompare\Program.cs
     目录           0  2020-06-28 15:30  ComparePicture\PictureCompare\Properties\
     文件        1336  2019-06-21 09:07  ComparePicture\PictureCompare\Properties\AssemblyInfo.cs
     文件        2868  2019-06-22 08:55  ComparePicture\PictureCompare\Properties\Resources.Designer.cs
     文件        5612  2019-06-21 09:07  ComparePicture\PictureCompare\Properties\Resources.resx
     文件        1114  2019-06-22 08:55  ComparePicture\PictureCompare\Properties\Settings.Designer.cs
     文件         249  2019-06-21 09:07  ComparePicture\PictureCompare\Properties\Settings.settings
     文件         134  2019-06-21 09:14  ComparePicture\PictureCompare\app.config
     目录           0  2020-06-28 15:30  ComparePicture\PictureCompare\bin\
............此处省略84个文件信息

评论

共有 条评论