Adaptive Median Filtering using MATLAB

May 27, 2007

MATLAB is a great tool. I recently wrote a code to perform an adaptive median filtering on a somewhat noisy image. The code works great in removing noise on an image…. It is a simple code that I wrote in a few minutes using MATLAB… for simplification the code does not render regions near the edges… the spatial mask which is a three by three window could not process the edges since it is out of bound…. I could have use padding and pad the edges so that the spatial mask can process the edges…. but you get the idea…and the code…Adaptive Filter

Adaptive median filtering is not the only way to remove noise on an image. It depends on the what kind of noise exists in the image. For example, if the image has a salt noise only, then using contraharmonic mean filter with Q=-1.5 probably will do the job, or if you have a pepper noise only, then using contraharmonic mean filter with Q=1.5 probably will do the job.

Also, extracting noise from an image, not necessarily we have to use time domain or spatial domain. We can also use the frequency domain such as by using band reject filter or notch filter to reject noises at certain region of the fourier spectrum.

Filed under: MATLAB

49 Comments Leave a Comment

  • 1. zahra  |  April 20, 2009 at 10:39 pm

    thank you for the post

    do you have any idea about wavelet denoising

  • 2. ridwan.chen  |  April 20, 2009 at 11:43 pm

    Hi Zahra. In a wavelet denoising for a 2D image, first you have to choose a wavelet of your choice. This can be a haar wavelet or any other symlets. You will also choose the scaling factor which will be your number of iterations. So for two iterations will give you two scale decomposition. Apply the chosen FWT to your image which consist of your digital filtering and downsampling. The denoising part comes here: you can use hard thresholding by setting zero to elements whose absolute values are lower that your pre-set threshold. Another method is soft thresholding whereby after performing hard thresholding, you then scale the non-zero coefficients toward zero. This can eliminates discontinuity in your resulting image later on. Last you will perform the wavelet reconstruction or synthesis part.

  • 3. omar  |  June 10, 2009 at 10:33 am

    Hi
    thaks for the post but the code of adaptive median filtering doesn’t exist
    i’ll plesaed if you can send it
    merci

  • 4. Ridwan.Chin  |  September 7, 2009 at 12:36 pm

    I will have it e-mail to you in a bit. Thanks…

  • 5. krishna  |  September 22, 2009 at 5:15 am

    hi……
    i am doing project on inage processing……..can you please send me the code of adaptive median filter to reome noise and extracting the original image without disturbing the fringes.
    if you send me the solution it would be very helpful and i will be thankfull to you…………

    with regards,
    kishore.

  • 6. ridwan.chen  |  September 27, 2009 at 9:50 pm

    Hi Kishore. You should have received the adaptive median filter m file by now. Good luck.

  • 7. Muthukumar  |  September 29, 2009 at 3:20 am

    I need adaptive medain filter for my project so I request you to sent the code.

  • 8. Shruti  |  September 30, 2009 at 7:31 am

    cn u plz forward me the code for adaptive median filter in matlab.
    Actually we are dng a project(classification of abnormal organs in abdomen using texture analysis of ct images) and are stuck on this algo.
    Can u suggest sm other filter which will b more suitable in our case..

  • 9. Saranya  |  October 6, 2009 at 7:51 am

    Hi
    Iam working on ECG signal processing and it wub be kind of you if you cud send me your code for me as a reference

    Thankyou,

    Regards,
    Saranya

  • 10. Saranya  |  October 6, 2009 at 7:54 am

    Hi
    If your familiar with ECG signals do let me know so that my discussions with you can help me progress in my project

    Awaiting you reply

    Saranya

  • 11. ridwan.chen  |  October 6, 2009 at 8:38 pm

    Those who requested the m file for adaptive median filter should have received it by now.

    Good Luck!

  • 12. ridwan.chen  |  October 6, 2009 at 8:40 pm

    Hi Saranya. I am much familiar with neuro stimulation than ECG. But please I am open to the discussion. Thanks!

  • 13. naren  |  October 12, 2009 at 8:07 am

    hi , i m working on median filter on ultrasound image.if u please send me the code for that,it will be of great help thanks…
    naren

  • 14. naren  |  October 14, 2009 at 2:01 am

    hi. i m doing project on median filtering on medical images.i will be very much thankful to u if u please send the m file to me at the earliest..thanks——-naren

  • 15. sholihex  |  October 16, 2009 at 5:42 am

    I need adaptive medain filter for my project so I request you to sent the code

  • 16. amoli  |  November 3, 2009 at 2:27 am

    hi……
    i am doing project on image processing.do you please send me the code of adaptive median filter to reome noise and extracting the original image without disturbing the fringes.
    if you send me the solution it would be very helpful and i will be thankfull to you…………

    with regards,
    amoli

  • 17. uma  |  November 10, 2009 at 6:42 am

    hai, i am in need of matlab code for adaptive median filter. kindly send me the code as soon as possible

  • 18. Kumar Samay  |  November 11, 2009 at 9:30 am

    Hello Ridwan,

    I am involved with one of image processing project. It will be great if you can you send me the MATLAB code of adaptive median filtering for image processing?

    Thanks in advance.

  • 19. Kumar samay  |  November 14, 2009 at 2:27 am

    Hello Ridwan Chendarma,

    Can you forward me the source code to do the adaptive median filtering. I want to utilise that code to do my study project. Thanks in advance.

  • 20. Somya  |  November 15, 2009 at 11:48 am

    Hello,

    I am doing a project in digital image processing on noise removal. Kindly send me the code for Adaptive median Filter. The one I made is creating problems at the edges. It would be great if I can get to know where I am going wrong by comparing it with yours.

    Regards
    Somya

  • 21. zahid  |  November 16, 2009 at 7:31 am

    Hi,
    Can you send me the matlab code of this filter.

    Regards!

  • 22. Kim Yong Hee  |  November 16, 2009 at 9:54 pm

    Hi, My name is Kim yong Hee..^^

    Could you send source about this adaptive median filtering.

    I am willing to be pleased your resopnse.

  • 23. Vandana  |  December 16, 2009 at 6:00 am

    Hi , can u send the adaptive median filter m file to me please ? I need it too ..

  • 24. soumya  |  December 18, 2009 at 10:27 am

    hi..
    Am doin a project in image processing.Il be glad if u could send the code for adaptive median filter usin matlab. It will be very helpful
    Thanku

  • 25. Shyam Lal Rao  |  December 24, 2009 at 12:21 pm

    Iam working on image processing and it would be kind of you if you could send me your code for me as a reference.

  • 26. Shyam Lal Rao  |  December 24, 2009 at 12:24 pm

    thanks a lot for providing a information abt adaptive median filter matlab code , which will be very useful for person who is perticularly field.

  • 27. chirag  |  January 7, 2010 at 11:02 am

    Hi,
    I m working on a project of image processing using AMF and bacterial foraging optimization..
    i m very new to this topic .
    if you can send your codeof AMF,it will be very helpful for me.
    Thanks in advance..

  • 28. sultan  |  January 15, 2010 at 6:53 am

    Hi;
    plz send me the code of adaptive median filtering

  • 29. ridwan.chen  |  January 16, 2010 at 1:05 am

    The requests have been overwhelming and I probably should post the programming skeleton so you can try it yourself and it should work!

    The adaptive median filter works in two levels. Lets label them level 1 and level 2.

    level 1: A1 = n_med – n_min
    A2 = n_med – n_max
    If A1 > 0 AND A2 < 0, Goto level 2
    Else increase the window size
    IF window size <= S_max repeat level 1
    Else output n_med
    level 2: B1 = n_xy - n_min
    B2 = n_xy - n_max
    If B1 > 0 AND B2 < 0, output n_xy
    Else output z_med

    Where, n_min = minimum gray level value in S_xy
    n_max = maximum gray level value in S_xy
    n_med = median of gray levels in S_xy
    n_xy = gray level at coordinates (x,y)
    S_max = maximum allowed size of S_xy

    So now go try ….

  • 30. prashanth  |  January 31, 2010 at 10:08 am

    sir can you please send me the code for adaptive median filtering as it is my project too

  • 31. kirank  |  March 16, 2010 at 7:49 am

    hello..im carrying out a project in image processing,i need ur guidance in doin so..do reply…waiting for ur response at the earliest.

  • 32. rajni  |  March 18, 2010 at 11:58 am

    plz send me code for adaotive median filter

  • 33. sudhee  |  April 9, 2010 at 11:06 am

    hi.. can u please send me the code for image denoising using ADAPTIVE MEDIAN FILTER.. it will be of great help.

  • 34. jaehoonLee  |  May 26, 2010 at 11:30 pm

    hi, i am in need of matlab code for adaptive median filter. kindly send me the code as soon as possible

  • 35. fathima  |  July 13, 2010 at 5:36 am

    plz i too want that code

  • 36. rahele  |  August 1, 2010 at 3:05 am

    Hi there

    Is it ok to let me have your matlab codes for adaptive median filter?

    Thank you in advance

  • 37. Hamid  |  August 13, 2010 at 2:59 am

    hi, i am in need of matlab code for adaptive median filter. kindly send me the code as soon as possible

  • 38. R.AARTHI  |  August 17, 2010 at 4:51 am

    hai..i need verilog or matlab code for adaptive median filter for my project.. pls mail me soon.. thanks

  • 39. Anu  |  November 1, 2010 at 3:43 am

    My project is about noise removal in images using Adaptive Rank Order Filter.Kindly send me the matlab source code for this filter which is more efficient than AMF. Reply me as early as possible since we are in need to complete it soon

  • 40. tatiyana  |  November 9, 2010 at 3:14 pm

    hi, i m doing project in image processing. can u plz help me, by sending ur code
    i m vry grateful to u

  • 41. Amy Chiang  |  November 17, 2010 at 7:13 pm

    Hi, I need the matlab code for adaptive median filter. Could you please send me the code? Thank you very much.

  • 42. suresh  |  November 29, 2010 at 2:51 am

    hai..,
    i’m working on image processing..please send the code for amf..
    i have a code written for it but it working some times ‘i mean it showing completly filterd images after running few times (same code)other times it showing pritially filterd image;
    the window loop to find max&min values is not executting by checking in work space it stoping at some intermediate vale’.
    it showing completly filterd image when loop is executing fully.
    im not changing any code ,after few run’s it showing good result..
    plz help me

  • 43. munir  |  January 2, 2011 at 12:16 pm

    Can you pleae email me the code for adaptive median filtering

  • 44. rajesh  |  April 15, 2011 at 9:57 pm

    can u send me adaptive median filter using matlab code…………..i need it pls

  • 45. poornima  |  May 13, 2011 at 10:49 pm

    sir can u send me the code bcoz iam also working on that filters

  • 46. Verity  |  May 21, 2011 at 4:02 am

    Thanks for your post. Can I know the source code of your program. I’ve tried many time to program this filter but nothing work.

    Thanks in Advance and Best Regards…

  • 47. sheoran neeraj  |  May 25, 2011 at 2:51 am

    send me the code for mean & median filter for matlab
    thank and regardx

  • 48. Anusha  |  May 26, 2011 at 2:11 pm

    Hi ridwan

    i’m doing my project in video denoising, for which i need to implement AME too. It’ll be so kind of you if you can send me your adaptive median filter MATLAB code.

    Thanks in advance

    Anusha

  • 49. pram  |  June 8, 2011 at 7:22 pm

    Hi can you please send me the code for this, its purely for study purposes

Leave a Comment

(required)

(required), (Hidden)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

TrackBack URL  |  RSS feed for comments on this post.


 

May 2007
M T W T F S S
« Mar   Jun »
 123456
78910111213
14151617181920
21222324252627
28293031  

Pages

Blogroll

Categories