Thread: A little trouble implementing a blur filter

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    20

    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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    20
    It would be great if I could use the container you mention, but I have to do it by hand

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble adding source filter for WMV
    By abachler in forum Windows Programming
    Replies: 2
    Last Post: 07-03-2008, 08:38 AM
  2. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  3. Having trouble implementing enumeration.
    By RP319 in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2005, 07:03 PM
  4. Replies: 4
    Last Post: 03-02-2003, 09:12 AM
  5. writing a gaussian blur filter
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 06-04-2002, 08:02 AM