function g = apply_point_transform(f,T) % Function to apply the transformation in T to the image f [nr nc] = size(f); g = zeros(nr,nc); % Loop over all the pixels for idx1 = 1:nr for idx2 = 1:nc % Pull out the gray level from f r = f(idx1,idx2); %Index into T to find the new gray level s = T(r+1); % Load the new gray level into the output image g g(idx1,idx2) = s; end end