# A little trouble implementing a blur filter

• 04-15-2006
omishompi
A little trouble implementing a blur filter
I've got the concept of blurring an image down, but I have not a clue as to how to implement it. I know it starts with manipulation of a pixel and it's eight neighbors. I'm using a .pgm as an example, so manipulating integers is the goal.

c c c
c 1 c
c c c <-------so that's the problem

Now take the mean of the surrounding pixels right?
I've also seen it as 1/4 * original pixel + 1/8 * sum of horizontal and vertical pixels + 1/16 * sum of diagonal pixels.

Can someone lead me down the right track on coding this stuff?

Also, isn't there a problem with the extreme edges if the algorithm is made like above? So you'd end up with

- - - - -
- c c c -
- c 1 c -
- c c c -
- - - - - with the hyphens being unfiltered?

Any help if greatly appreciated
• 04-15-2006
Salem
Like as in
newbm[y][x] = filterfn( oldbm, x, y );

> Also, isn't there a problem with the extreme edges if the algorithm is made like above?
My guess is that you should just propagate the edge pixel into the border, then apply the same rules as normal.
• 04-16-2006
omishompi
It would be great if I could use the container you mention, but I have to do it by hand :(