I'm trying to write a filtering function for an image, but I can't seem to wrap my head around (or remember) how to transfer all that math theory into code.
Lets say I have the following function, where the ints inside the arrays are integers between 0
and 255
(pretty much grayscale pixels to keep it simple).
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;
}
Right now I'm stuck trying to figure out how to use filters. I've been trying wikipedia but I find the articles they have there not particularly helpful. Can anyone clue me in on this or knows of any simple code sample?