def test_denoise_tv_chambolle_3d():
 (x, y, z) = np.ogrid[0:40, 0:40, 0:40]
 mask = (((((x - 22) ** 2) + ((y - 20) ** 2)) + ((z - 17) ** 2)) < (8 ** 2))
 mask = (100 * mask.astype(np.float))
 mask += 60
 mask += (20 * np.random.rand(*mask.shape))
 mask[(mask < 0)] = 0
 mask[(mask > 255)] = 255
 res = restoration.denoise_tv_chambolle(mask.astype(np.uint8), weight=0.1)
 assert_((res.dtype == np.float))
 assert_(((res.std() * 255) < mask.std()))

def test_denoise_tv_chambolle_3d ( ) : ( x , y , z ) = np . ogrid [ 0 : 40 , 0 : 40 , 0 : 40 ] mask = ( ( ( ( ( x - 22 ) ** 2 ) + ( ( y - 20 ) ** 2 ) ) + ( ( z - 17 ) ** 2 ) ) < ( 8 ** 2 ) ) mask = ( 100 * mask . astype ( np . float ) ) mask += 60 mask += ( 20 * np . random . rand ( * mask . shape ) ) mask [ ( mask < 0 ) ] = 0 mask [ ( mask > 255 ) ] = 255 res = restoration . denoise_tv_chambolle ( mask . astype ( np . uint8 ) , weight = 0.1 ) assert_ ( ( res . dtype == np . float ) ) assert_ ( ( ( res . std ( ) * 255 ) < mask . std ( ) ) )
apply the tv denoising algorithm on a 3d image representing a sphere .