首页 > 解决方案 > 图像之间的平等c#

问题描述

我需要比较两张图片,看看它们是否相同。

图片仅包含文字。

我在硬盘上保存了一张图像,我需要查看它是否与我正在下载的图像相同。

我尝试使用此代码建立 5% 的误差范围,但我遇到的主要问题是图像文本可以在 0 到 30 度或 0 到 -30 度之间旋转

int width;
int height;
if (bmp1.width < bmp2.width)
{
    width = bmp1.width;
}
else
{
    width = bmp2.width;
}
if (bmp1.heigth < bmp2.width)
{
    heigth = bmp1.heigth;
}
else
{
    heigth = bmp2.heigth;
}
int contador = 0;

for (int x = 0; x < width; x++)
{
    for (int y = 0; y < height; y++)
    {
        if (bmp1.GetPixel(x, y) == bmp2.GetPixel(x, y))
        {
            contador++
        }
    }
}
int similar_percent = (contador / (height * width) * 100);

我留下两个图像的小例子

标签: c#image

解决方案


推荐阅读