|
|
@ -3046,11 +3046,11 @@ def unfinished_smoothn(data,s=None, weight=None, robust=False, z0=None, tolz=1e-
|
|
|
|
# Lambda contains the eingenvalues of the difference matrix used in this
|
|
|
|
# Lambda contains the eingenvalues of the difference matrix used in this
|
|
|
|
# penalized least squares process.
|
|
|
|
# penalized least squares process.
|
|
|
|
d = y.ndim
|
|
|
|
d = y.ndim
|
|
|
|
Lambda = zeros(sizy)
|
|
|
|
Lambda = np.zeros(sizy)
|
|
|
|
siz0 = (1,)*d
|
|
|
|
siz0 = (1,)*d
|
|
|
|
for i in range(d):
|
|
|
|
for i in range(d):
|
|
|
|
siz0[i] = sizy(i)
|
|
|
|
siz0[i] = sizy(i)
|
|
|
|
Lambda = Lambda + cos(pi*np.arange(sizy(i))/sizy[i]).reshape(siz0)
|
|
|
|
Lambda = Lambda + np.cos(pi*np.arange(sizy(i))/sizy[i]).reshape(siz0)
|
|
|
|
siz0[i] = 1
|
|
|
|
siz0[i] = 1
|
|
|
|
|
|
|
|
|
|
|
|
Lambda = -2*(d-Lambda)
|
|
|
|
Lambda = -2*(d-Lambda)
|
|
|
@ -3074,7 +3074,7 @@ def unfinished_smoothn(data,s=None, weight=None, robust=False, z0=None, tolz=1e-
|
|
|
|
Wtot = W;
|
|
|
|
Wtot = W;
|
|
|
|
# Initial conditions for z
|
|
|
|
# Initial conditions for z
|
|
|
|
if weight is None:
|
|
|
|
if weight is None:
|
|
|
|
z = zeros(sizy)
|
|
|
|
z = np.zeros(sizy)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# With weighted/missing data
|
|
|
|
# With weighted/missing data
|
|
|
|
# An initial guess is provided to ensure faster convergence. For that
|
|
|
|
# An initial guess is provided to ensure faster convergence. For that
|
|
|
@ -3146,10 +3146,10 @@ def unfinished_smoothn(data,s=None, weight=None, robust=False, z0=None, tolz=1e-
|
|
|
|
|
|
|
|
|
|
|
|
# Warning messages
|
|
|
|
# Warning messages
|
|
|
|
if isauto
|
|
|
|
if isauto
|
|
|
|
if abs(log10(s)-log10(sMinBnd))<errp
|
|
|
|
if abs(np.log10(s)-np.log10(sMinBnd))<errp
|
|
|
|
warnings.warn('''s = %g: the lower bound for s has been reached.
|
|
|
|
warnings.warn('''s = %g: the lower bound for s has been reached.
|
|
|
|
Put s as an input variable if required.''' % s)
|
|
|
|
Put s as an input variable if required.''' % s)
|
|
|
|
elif abs(log10(s)-log10(sMaxBnd))<errp:
|
|
|
|
elif abs(np.log10(s)-np.log10(sMaxBnd))<errp:
|
|
|
|
warnings.warn('''s = %g: the Upper bound for s has been reached.
|
|
|
|
warnings.warn('''s = %g: the Upper bound for s has been reached.
|
|
|
|
Put s as an input variable if required.''' % s)
|
|
|
|
Put s as an input variable if required.''' % s)
|
|
|
|
|
|
|
|
|
|
|
@ -3196,22 +3196,19 @@ def unfinished_smoothn(data,s=None, weight=None, robust=False, z0=None, tolz=1e-
|
|
|
|
W[isnan(W)] = 0
|
|
|
|
W[isnan(W)] = 0
|
|
|
|
return W
|
|
|
|
return W
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initial Guess with weighted/missing data
|
|
|
|
# Initial Guess with weighted/missing data
|
|
|
|
def z = InitialGuess(y,I):
|
|
|
|
def z = InitialGuess(y,I):
|
|
|
|
# nearest neighbor interpolation (in case of missing values)
|
|
|
|
# nearest neighbor interpolation (in case of missing values)
|
|
|
|
if any(~I(:))
|
|
|
|
if (1-I).any():
|
|
|
|
if license('test','image_toolbox')
|
|
|
|
if license('test','image_toolbox')
|
|
|
|
z, L = distance_transform_edt(1-I, return_indices=True)
|
|
|
|
z, L = distance_transform_edt(1-I, return_indices=True)
|
|
|
|
[z,L] = bwdist(I);
|
|
|
|
[z,L] = bwdist(I);
|
|
|
|
z = y;
|
|
|
|
z = y;
|
|
|
|
z(~I) = y(L(~I));
|
|
|
|
z(~I) = y(L(~I));
|
|
|
|
else
|
|
|
|
else
|
|
|
|
% If BWDIST does not exist, NaN values are all replaced with the
|
|
|
|
#% If BWDIST does not exist, NaN values are all replaced with the
|
|
|
|
% same scalar. The initial guess is not optimal and a warning
|
|
|
|
#% same scalar. The initial guess is not optimal and a warning
|
|
|
|
% message thus appears.
|
|
|
|
#% message thus appears.
|
|
|
|
z = y;
|
|
|
|
z = y;
|
|
|
|
z(~I) = mean(y(I));
|
|
|
|
z(~I) = mean(y(I));
|
|
|
|
warning('MATLAB:smoothn:InitialGuess',...
|
|
|
|
warning('MATLAB:smoothn:InitialGuess',...
|
|
|
|