%% Function that perform 1D-Integer Wavelet Transform
function [out]=dwt_1d(x_image)
[m n]=size(x_image);

for k=1:m
     x=x_image(k,:);
     
x_even_a =x(1);
x_odd=x(2);
x_even_b=x(3);
n=length(x);

if (mod(n,2)==1) 
    nn_h=(n+1)/2;
    nn_l=(n-1)/2;
else
    nn_l=(n+1)/2;
    nn_h=(n-1)/2;
end;

dsthi=1;
dstlo=1;
srcadr=2;
h=filter_odd(x_odd,x_even_a,x_even_b);
hi_b=h;
hi_a=h;
i=1;

while i < (n-1) 
    
    hh(dsthi)=hi_b;
    lo=filter_even(x_even_a,hi_a,hi_b);
    ll(dstlo)=lo;
    i=i+2;
    
    srcadr=srcadr +2;
    dsthi=dsthi+1;
    dstlo=dstlo+1;
    
    if  i < (n-1) 
        
         hi_a=hi_b;
         x_even_a=x_even_b;
         x_odd=x(srcadr);
         x_even_b=x(srcadr+1);
         hi_b=filter_odd(x_odd,x_even_a,x_even_b);
     end ;
     
 end ;
 
 if ( mod(n,2)~= 0) 
     
     lo=filter_even(x_even_b,hi_b,hi_b);
     ll(dstlo)=lo;
 else
     x_odd=x(srcadr);
     hi_a=filter_odd(x_odd,x_even_a,x_even_b);
     
     lo=filter_even(x_even_b,hi_b,hi_a);
     hh(dsthi)=hi_a;
     ll(dstlo)=lo;
     
 end ;
        
    out(k,:)=[ll hh];
end;

