function ima_out = transform(ima_in,T)

maxT = size(T,1);
s = size(ima_in);
scale = maxT / 255.0;
ima = double(ima_in);
for i = 1 : s(1)
   for j = 1 : s(2)
      index = round(ima(i,j)*scale+0.5);
      ima_out(i,j) = round(255.0*T(index));
   end
end
