function OUT = ihwt(IN, iterations);

[a,b] = size(IN);
a = a / 2^(iterations-1);
b = b / 2^(iterations-1);
count = 0;

OUT = IN;
OUT1 = IN;

while count < iterations

index = 1;
j = 1;
k = 1;
while j < a,
  for k = 1:b,
    OUT1(j,k) = (IN(index,k) + IN(index+a/2,k));
    OUT1(j+1,k) = (IN(index,k) - IN(index+a/2,k));
  end
  j = j+2;
  index = index+1;
end

k = 1;
j = 1;
index = 1;

while k <= b,
  for j = 1:a,
    OUT(j,k) = (OUT1(j,index) + OUT1(j, index+b/2));
    OUT(j, k+1) = (OUT1(j,index) - OUT1(j, index+b/2));
  end
  k = k + 2;
  index = index+1;
end

count = count+1;
a = a*2;
b = b*2;
IN = OUT;

end

OUT = round(OUT);
