嗨,所以我必须制作一个脚本(与哪种编程语言无关,例如,在这里我将使用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 !
}
}
所以这是我需要您帮助的地方,我真的不知道该如何处理。
我认为这需要一些我喜欢的数学公式。
如果有人提供帮助或提示可以引导我走正确的道路,我将不胜感激。谢谢。
最佳答案
对图像进行模糊处理(例如,使用高斯模糊处理)时,实际上是对图像的像素进行一些“平均”处理,这意味着使边缘变得“更平滑”。
因此,要检查一个图像是否具有“平滑”边缘,然后检查其他图像,可以像Jan Dvorak建议的那样查看图像的渐变,但不要忘记通过图像中的像素数量对其进行归一化处理(否则将得到较大的图像结果较大)。
如果要检查两个完全不同的图像,则测试会复杂得多,因为不同的场景自然会具有不同的平滑度