pointOp.m 1.2 KB

12345678910111213141516171819202122232425262728
  1. % RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS)
  2. %
  3. % Apply a point operation, specified by lookup table LUT, to image IM.
  4. % LUT must be a row or column vector, and is assumed to contain
  5. % (equi-spaced) samples of the function. ORIGIN specifies the
  6. % abscissa associated with the first sample, and INCREMENT specifies the
  7. % spacing between samples. Between-sample values are estimated via
  8. % linear interpolation. If WARNINGS is non-zero, the function prints
  9. % a warning whenever the lookup table is extrapolated.
  10. %
  11. % This function is much faster than MatLab's interp1, and allows
  12. % extrapolation beyond the lookup table domain. The drawbacks are
  13. % that the lookup table must be equi-spaced, and the interpolation is
  14. % linear.
  15. % Eero Simoncelli, 8/96.
  16. function res = pointOp(im, lut, origin, increment, warnings)
  17. %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD)
  18. fprintf(1,'WARNING: You should compile the MEX version of "pointOp.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n');
  19. X = origin + increment*[0:size(lut(:),1)-1];
  20. Y = lut(:);
  21. res = reshape(interp1(X, Y, im(:), 'linear', 'extrap'),size(im));