2

两张图片

嗨,所以我必须制作一个脚本(不管是什么编程语言,但我会在这里使用 Java),一个比较两张黑白图像并判断哪一张最模糊的脚本。

所以我必须做一个这样的功能:

function int getImageBlurPercentage()
{
    ArrayList<Integer> ColorList = new ArrayList<Integer>();

    //Part 1: fill ColorList with color values (0=black, 255=white)

    go through Y axis
        go through X axis
            ColorList -> add colorValue of each pixel; [ie: 0 to 255]


    //Part 2: process (This is the part where I need help !)

    int lastColor = 0;

    for(int color : ColorList)
    {
        // Something has to be done here
        // To compare pixel by pixel
        // and get noise result or difference result
        // and convert it to a percentage (0% - 100%)
        // This is where I need your help !
    }
}

所以这就是我需要你们帮助的地方,我真的不知道如何处理这个问题。我认为这需要一些我不擅长的数学公式。

如果有人帮助或提供可以引导我走上正确道路的提示,我将不胜感激。谢谢你。

4

1 回答 1

0

当您模糊图像时(假设您使用高斯模糊),您实际上对图像的像素进行了一些“平均”,这意味着您使边缘“更平滑”。

因此,要检查一个图像是否比其他图像具有“更平滑”的边缘,您可以像 Jan Dvorak 建议的那样查看图像的渐变,但不要忘记通过图像中的像素数量对其进行归一化(否则会得到更大的图像更大的结果)。

如果要检查两个完全不同的图像,测试会复杂得多,因为不同的场景自然有不同的平滑度

于 2012-12-27T23:29:55.527 回答