Commit b5a06ee1 authored by Alessandro Mirone's avatar Alessandro Mirone
Browse files

written

parent 338774ca
......@@ -11,6 +11,63 @@ try:
except:
print( " ATTENTION : SKIMAGE RESORATION NOT LOADED ")
def mdiv(grad):
res = np.zeros(grad.shape[1:])
res[ :-1 , :, : ] += this_grad[0, :-1 , :,:]
res[ 1:-1 , :, : ] -= this_grad[0, :-2 , :,:]
res[ -1 , :, : ] -= this_grad[0, -2 , :,:]
res[ :, :-1 , : ] += this_grad[0, :, :-1 ,:]
res[ :, 1:-1 , : ] -= this_grad[0, :, :-2 ,:]
res[ :, -1 , : ] -= this_grad[0, :, -2 ,:]
return res
def mygradient(img):
shape = [2 ] + list(img.shape)
gradient = np.zeros(shape, dtype=img.dtype)
gradient[0,:,:,: ] = np.diff(img, axis=0)
gradient[1,:,:,: ] = np.diff(img, axis=1)
return gradient
def v_project(v,weight ):
norms = np.minimum( weight, np.sqrt( v[0]*v[0] + v[1]*v[1] ))
return v/ norms
def my_denoise_tv_chambolle_positive(image, weight=0.1, n_iter_max):
ndim = image.ndim
g = np.zeros_like(p)
x = np.zeros_like(image)
tmpxa = np.zeros_like(image)
v = np.zeros((image.ndim, ) + image.shape, dtype=image.dtype)
i = 0
sigma = 1.0/math.sqrt(8.0)
tau = 1.0/math.sqrt(8.0)
while i < n_iter_max:
tmpxa[:] = x + sigma * ( ( image-x) + mydiv( v ) )
tmpxa[:] = np.maximum (tmpxa)
tmpxa[:] = tmpxa-x
x[:] = x + tmpxa
tmpxa[:] = x + tmpxa
v[:] = v + tau * mygrad(tmpxa)
v = v_project(v,weight )
return x
def superr( scalDD, scalDS, scalSS, niter=15, beta=1.0e-8):
"""
- scalDS which is an array [ZDIM,YDIM,XDIM] , type "d" .
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment