【发布时间】:2009-10-20 13:17:31
【问题描述】:
我正在尝试为图像编写一个过滤函数,但我似乎无法理解(或记得)如何将所有数学理论转化为代码。
假设我有以下函数,其中数组内的整数是 0 和 255 之间的整数(为了简单起见,使用了相当多的灰度像素)。
private int[][] resample(int[][] input, int oldWidth, int oldHeight,
width, int height)
{
int[][] output = createArray(width, height);
// Assume createArray creates an array with the given dimension
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
output[x][y] = input[x][y];
// right now the output will be "cropped"
// instead of resampled
}
}
return output;
}
现在我一直在试图弄清楚如何使用过滤器。我一直在尝试维基百科,但我发现 articles they have 没有特别有用。任何人都可以提示我或知道任何简单的代码示例吗?
【问题讨论】:
-
您是否故意不使用 Java API 来调整图像大小?是为了锻炼吗?作业?
-
我正在使用 Processing.org。我的代码比这复杂一点,输入是一个重复模式(我已经编写了一个函数来从中获取像素)。在创建输出图像然后使用处理 API 调整其大小时,我最终遇到了 OutOfMemoryErrors。因为最后我希望它调整大小,所以我通过自己生成调整大小的版本来避免不必要地浪费 Java 中的堆空间。
标签: java image-processing signal-processing