function y = filtreii(h,g,x)
%        y = filtreii(h,g,x)
% g*y = h*x
% filtrage rii recentre + recalage entre 0 et 255
%------------------------------------------------

if min(size(x)) > 1
  error('le signal doit etre un vecteur');
end
x = x(:)';
L = length(x);

ret = retard(h,g);
I = [x, zeros(1,ret)];
y = filter(h,g,I);
y = y(ret+1:end);
y = recale(y);
y = round(y);

%------------------------------------------------
function ret = retard(h,g)
%------------------------------------------------
 dirac = zeros(1,1000);
 dirac(1) = 1;
 h = filter(h,g,dirac);
 h = abs(h);
 M = max(h);
 ret = find(h == M);
 ret = ret(1)-1;
 