Paul Clapham wrote:So you don't even need a 1-D array, then.
Ana Yo wrote:To prove to you that I'm actually trying and putting effort: this is what i have so far:
I think my logic is kinda wrong. Would you mind fixing it?
Carey Brown wrote:Well, to average any set of numbers you need two things: a sum, and a count.
Ana Yo wrote:None
Ana Yo wrote:Say that the original values are in the 2D array "image". Compute the smoothed array by doing this:
Each value smooth[r][c] is the average of nine values:
image[r-1][c-1], image[r-1][c ], image[r-1][c+1],
image[r ][c-1], image[r ][c ], image[r ][c+1],
image[r+1][c-1], image[r+1][c ], image[r+1][c+1].
Paul Clapham wrote:Here's a pseudo-code version of what your code should look like:
m[i][j] == 1 ... cell is 1
!(i == r && j == c) ... You're asking whether [i, j] is a neighbor of [r, c] and you're saying it can't be a neighbor if it's the same as [r, c]