8-Moving Average In 2D

So what about images? Well images are two dimensional, and doing this in 2D is pretty straight forward extension of 1D with a, with a little bit of a flip. so let's do a moving average in 2D. I hope you can see that there's a whole bunch of zeroes in this picture over here. You see all those zeroes? And then in the middle on the bright area are these 90's. So this maybe is an image that goes from zero to 100, or whatever. But the idea is that zeroes are dark, and 90's are bright.

And what I'm going to do is I'm going to take a moving average, so here I have my little average right? It's a three by three average, and I'm going to take the middle pixel, over here and I'm going to put that average over there. Okay? So if I put my average overall at zeros and I take an average of all zeros.  Okay, it's zero.

So now we move our square over one. Right so we, we move it over here, we get zero, zero, zero, zero, zero, zero, 90, okay. What's the average of that going to be? Well, you can think of each of these as one ninth, so one ninth times zero summed up eight times plus 90. That average is going to be ten. Okay? So it turns ten, and then I slide it over one more, and now I get 290, so its average is going to be what? 20. And keep going. I get 30, and keep going further to 30, so I'm just moving this along, replacing the average. And finally, I get this total averaged value, right? And you can see that by putting a three by three, I get this nice bright area right around here which is where my three by three can sit over all the 90 values. And everywhere else it sort of falls off. And you'll notice the user zeroes here until we get to these tens. Where do those 10s come from? They come from this one little, bright spot there. Okay? And one of the things, by the way, you may have noticed is, by the boundaries we get these fun, kind of dark values. And we're going to talk more about, boundary conditions in a minute. All right. 

Last modified: Saturday, 17 February 2024, 5:37 PM