【发布时间】:2012-12-12 13:16:39
【问题描述】:
您好,所以我必须编写一个脚本(不管是什么编程语言,但我将在这里使用 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 !
}
}
所以这就是我需要你们帮助的地方,我真的不知道如何处理这个问题。 我认为这需要一些我不擅长的数学公式。
如果有人帮助或提供可以引导我走向正确道路的提示,我将不胜感激。谢谢。
【问题讨论】:
-
FFT 并比较最高频率?如果模糊后没有添加任何噪点,这将起作用。
-
FFT 并比较所有频率(加权)?这应该是可靠的。
-
@JanDvorak 我不知道这是什么意思,你能举个例子吗?
-
FFT = 快速傅里叶变换。傅里叶变换将数据从空间域变换到频域。
-
然后整合渐变量:
foreach x,y sum += (2 * p[x][y] - p[x-1][y] - p[x][y-1])。这很简单。
标签: java image-processing colors percentage