Code covered by the BSD License  

Highlights from
Toolbox Graph

image thumbnail
from Toolbox Graph by Gabriel Peyre
A toolbox to perform computations on graph.

perform_saturation(x,tau,use_mad)
function x = perform_saturation(x,tau,use_mad)

% perform_saturation - saturate a vector for better contrast
%
%   x = perform_saturation(x,tau,use_mad);
%
%   tau (around 1) is the saturation factor
%
%   copyright (c) 2007 Gabriel Peyre

if nargin<2
    tau = 1;
end
if nargin<3
    use_mad = 1;
end

tau = 2;
x = x-mean(x(:)); 
x = clamp( x/(2*mad(x(:))), -tau,tau);

Contact us at files@mathworks.com