Code covered by the BSD License

### Highlights from Non-Local Means Filter

4.22222
4.2 | 19 ratings Rate this file 99 Downloads (last 30 days) File Size: 2.22 KB File ID: #13176 Version: 1.0

# Non-Local Means Filter

### Jose Vicente Manjon-Herrera (view profile)

29 Nov 2006 (Updated )

Non-Local Means Filter for image denoising

File Information
Description

Implementation of the Non-Local Means Filter proposed by Buades et al. for robust image denoising.

typical usage:

fima=nlmeans(ima,5,2,sigma);

being sigma the noise standard deviation

MATLAB release MATLAB 7.0.1 (R14SP1)
16 Mar 2016 chao zhang

### chao zhang (view profile)

I have a great hope to download the code justnow, i wish it will give me great help!

16 Mar 2016 chao zhang

### chao zhang (view profile)

04 Nov 2015 Jing Hu

### Jing Hu (view profile)

01 Oct 2015 Javier Agustin Romero

### Javier Agustin Romero (view profile)

Thanks for the contribution, Jose.

28 Apr 2015 li teng

### li teng (view profile)

31 Mar 2015 Tarun Katyal

### Tarun Katyal (view profile)

for i=1:m
for j=1:n

i1 = i+ f;
j1 = j+ f;

W1= input2(i1-f:i1+f , j1-f:j1+f);

wmax=0;
average=0;
sweight=0;

rmin = max(i1-t,f+1);
rmax = min(i1+t,m+f);
smin = max(j1-t,f+1);
smax = min(j1+t,n+f);

for r=rmin:1:rmax
for s=smin:1:smax

if(r==i1 && s==j1) continue; end;

W2= input2(r-f:r+f , s-f:s+f);

could someone explain how are these W1 and W2 points calculated??
plz help not able to understand the code

Comment only
27 Sep 2013 John

### John (view profile)

I believe there is a bug in this code. If you change the line in demo.m, to display the error between the filtered and original images, i.e. from:

subplot(2,2,4),imagesc(rima-fima),title('residuals');

to

subplot(2,2,4),imagesc(ima-fima),title('residuals');

There is a clear bias/issue with the lower left hand quadrant edges, but not with the upper right hand quadrant edges.

Comment only
05 Jul 2013 Vikram Venkatraghavan

### Vikram Venkatraghavan (view profile)

25 Apr 2013 selma

### selma (view profile)

thanks for helping us

Comment only
21 Mar 2013 Prabhakar

### Prabhakar (view profile)

Suggest me how to give external image by applying this code

max(a,b)
what is the return type its array or int value i am getting trouble when i am implementing in java

Comment only
10 Jul 2011 Zhang Xuande

### Zhang Xuande (view profile)

cool!!

05 Dec 2010 YoonOh Tak

### YoonOh Tak (view profile)

Is this line right?

fima=NLmeansfilter(ima,5,2,sigma);

I think it has to change like below

fima=NLmeansfilter(rima,5,2,sigma);

09 Oct 2010 priyanka reddy

### priyanka reddy (view profile)

i have the same doubt what crisitna asked. can you help me. can u send me the modified codings

08 Oct 2010 Royi Avital

### Royi Avital (view profile)

Hello.
You mention to have the "Original" version which is slower yet easier to understand,
Where can I find it?
Thanks.

Comment only
08 Dec 2009 Tai Fei

### Tai Fei (view profile)

Hi, Jose, I have 2 questions on the kernel.
1). Is it gaussian kernel which is mentioned in the paper of Buades. As far as i know, the one in your code is not gaussian.
2). why you take these two steps ?
average = average + wmax*input2(i1,j1);
sweight = sweight + wmax;

I cannot find any ground in the original paper, but it does make my algorithm oscillate less. could you give me some idea, why you make them ?

24 Nov 2009 Victor Lee

### Victor Lee (view profile)

Hi Jose, you've mention of the bug earlier on but I can't seem to find it. Is it rectified and updated?

24 Nov 2009 Abhishek Bansal

### Abhishek Bansal (view profile)

how to calculate sigma, h and f? I am confused. I am a student, need urgent help. u can also email me at abhishek85bansal@gmail.com

Comment only
15 Oct 2009 Haoheng Zheng

### Haoheng Zheng (view profile)

Good, but few notation...

05 Aug 2009 Vijay

### Vijay (view profile)

Performance of the algorithm will depend on the sigma estimation in noisy image. How to estimate good sigma?

17 Apr 2009 cristina

### cristina (view profile)

I must define input,f,t,h...I'm not sure that I know how!
Can you help me please?I'm a beginer in matlab...thank you!

Comment only
17 Apr 2009 cristina

### cristina (view profile)

I have a little error here [m n]=size(input); in NLmeansfilter.m:

> NLmeansfilter
??? Input argument 'input' is undefined.

Error in ==> C:\Documents and Settings\Iulia\Desktop\matlab\NLmeansfilter.m
On line 19 ==> [m n]=size(input);

I need help...Thanks!

Comment only
22 Sep 2008 Jose Manjon

You are right Bi Yiming.

Jose

Comment only
01 Sep 2008 Bi Yiming

i think it should be
fima=NLmeansfilter(rima,5,2,sigma);
not fima=NLmeansfilter(ima,5,2,sigma);
in demo.m

31 Jul 2008 Kevin Verghese

d = sum(sum(kernel.*(W1-W2).*(W1-W2)));
This line throws an error.
"Error using ==> times
Integers can only be combined with integers of the same class, or scalar doubles."
How do we rectify that?

Comment only
31 Jul 2008 Jose Manjon

You have to use sigma, not 10*sigma

being signa the image noise standard deviation

Jose

Comment only
14 Jul 2008 Roger Ting

How to set the sigma for the algorithm.I chose 10*noisesigma, the result is very bad.

Comment only
28 Nov 2007 Reza Farrahi Moghaddam

Good Work,

Only, please change the word "radio" to "size" (in the definitions of "t" and "f")

Thanks

13 Aug 2007 victor diaz
16 Jul 2007 Jose Manjon

The original code was not optimized to easily understand the filter caracteristics. Now, I have already vectorized it to speed up the filter. New version is much faster but if you plan to use it rutinarily I suggest you to mex it.

Comment only
13 Jan 2007 Peter L

It is really slow. You need to vectorize it.

12 Dec 2006 Jose Manjon

There is a small bug in the code, please
chage:

k=max(abs(i),abs(j));

for

k=max([abs(i),abs(j),1]);

enjoy the filter

Jose Manjon

Comment only
02 Dec 2006 James Chan

cool