Thread: Median filter help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    6

    Median filter help

    Hello everyone, I am trying to create a program(within MATLAB) that will take a m(rows) x n(columns) matrix(example a 3x3 matrix), surround the perimeter of the matrix with zeroes, making it a 5x5 matrix. What I am trying to do is create a 2d median filter.

    [1 2 3]
    [4 5 6]
    [7 8 9]

    [0 0 0 0 0]
    [0 1 2 3 0]
    [0 4 5 6 0]
    [0 7 8 9 0]
    [0 0 0 0 0]

    also take the median(kernel) of odd sizes, such as 3x3, 5x5, 7x7 and so on. for example, take the first nine for a 3x3 which will be:

    [0 0 0]
    [0 1 2]
    [0 4 5]

    placing the numbers of the matrix in order: (0,0,0,0,0,1,2,4,5), taking the median which in this case of a 3x3...the 5th number(0) will replace the center value 1. and then the 3x3 kernel will slide to the left one and take the median of:
    [0 0 0]
    [1 2 3]
    [4 5 6] and replacing the center value 2 and slide over again and repeat the sequence until all center values of the mxn matrix are replaced.

    I was told for loops would work but ive had no luck so far. any help would be greatly appreciated and please make comments in the steps so I can understand what each line does.
    Thanks
    -Greg
    Last edited by JTEK24; 07-04-2009 at 11:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  2. moving median function
    By supermeew in forum C Programming
    Replies: 0
    Last Post: 05-04-2006, 02:37 PM
  3. Simple Filter
    By 00Sven in forum C Programming
    Replies: 3
    Last Post: 03-14-2006, 08:46 PM
  4. Computing Mean, Median and Mode Using Arrays
    By Rodneo in forum C++ Programming
    Replies: 0
    Last Post: 05-29-2002, 11:40 PM
  5. median
    By frank in forum C++ Programming
    Replies: 4
    Last Post: 10-28-2001, 04:32 PM