function gcv = GCV2(x,t)

% GCV2 -- apply soft threshold + compute GCV in 2D
%  Usage
%    gcv = GCV2(x,t)
%  Inputs
%    x      input coefficients
%    t      threshold (must be scalar)
%  Outputs
%    gcv    the value of the gcv
%  Description
%    Applies soft-threshold t to all elements of x and computes GCV

[m,n] = size(x);
y = x;
res = abs(x) - t;
N0 = sum(sum(res < 0));
y = sign(x) .* res .* (res >= 0);

gcv = n*m * sum(sum((y-x).^2)) / N0^2 ;

