nipy/dipy — pull request #433 by samuelstjean (2014-10-03 19:44:21+00:00)
Title: Added local variance estimation

Fixes #432, Seems to gives the same thing as our closed source implementation of nlmeans so far.

This PR :

In [109]: estimate_sigma(d)
Out[109]:
array([ 31.94007111, 13.55418587, 13.74776077, 13.63606453,
13.67319965, 13.60422993, 13.56204987, 13.60548496,
13.76000309, 13.57973385, 13.72612858, 13.7350111 ,
13.65256119, 13.58515263, 13.66841412, 13.60126591,
13.58483315, 13.58515263, 13.643466 , 13.74186325,
13.59409237, 13.73767948, 13.60761738, 13.59641361,
13.73959732, 13.59790134, 13.73537064, 13.66113281,
13.63371849, 13.6424818 , 13.60521698, 13.59016132,
13.59904766, 13.62820435, 13.5684433 , 13.56952667,
13.57829094, 13.75860214, 13.63626385, 13.6825037 ,
13.62080669, 13.65673733, 13.69610214, 13.63846493,
13.74402618, 13.71609783, 13.57646942, 13.70084381,
13.6728611 , 13.65078163, 13.6009016 , 13.70344543,
13.71196938, 13.72620392, 13.63866806, 13.67575741,
13.74444294, 13.64913177, 13.7595911 , 13.60122585,
13.76624775, 13.66040325, 13.64105892, 13.72773266, 13.8091774 ], dtype=float32)

The other implementation :
Estimated standard deviation of noise :31.9401 --> Sigma = 31.9401
Estimated standard deviation of noise :13.5542 --> Sigma = 13.5542

I alos added a cheap check to remove zeros when the background is absent, which won't give the same numbers, but is close on the same test (the data has some background set to zero)

In [94]: estimate_sigma(d)
Out[94]:
array([ 32.0320015 , 13.59815121, 13.79326344, 13.68167877,
13.71766853, 13.64865971, 13.60599041, 13.64930344,
13.80526352, 13.62382603, 13.77113152, 13.77896404,
13.69764805, 13.62915134, 13.71269417, 13.64586449,
13.6284008 , 13.62946415, 13.68790531, 13.78582764,
13.63778496, 13.78283215, 13.65133572, 13.63971615,
13.78512955, 13.64159966, 13.77961826, 13.70498466,
13.67730331, 13.68666077, 13.64945412, 13.63408661,
13.64239788, 13.67206287, 13.61290073, 13.61320686,
13.62299824, 13.80318546, 13.68140888, 13.72596836,
13.66493225, 13.70094013, 13.74094391, 13.68257999,
13.78874302, 13.75980568, 13.62131596, 13.74606228,
13.71796322, 13.69530106, 13.64515877, 13.74870014,
13.75715065, 13.77051258, 13.68297386, 13.7193985 ,
13.78968048, 13.69384766, 13.80404091, 13.64589691,
13.81126785, 13.70522404, 13.68564224, 13.77248096, 13.85372639], dtype=float32)