X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fimage-1.0.15%2Fuintlut.m;fp=octave_packages%2Fimage-1.0.15%2Fuintlut.m;h=2caf6d740640ef5addb398238310b743a2c98201;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/image-1.0.15/uintlut.m b/octave_packages/image-1.0.15/uintlut.m new file mode 100644 index 0000000..2caf6d7 --- /dev/null +++ b/octave_packages/image-1.0.15/uintlut.m @@ -0,0 +1,62 @@ +## Copyright (C) 2004 Josep Mones i Teixidor +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see . + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{B} = } uintlut (@var{A},@var{LUT}) +## Computes matrix B by using A as an index to lookup table LUT. +## +## B = uintlut(A, LUT) calculates a matrix B by using @var{LUT} as a +## lookup table indexed by values in @var{A}. +## +## B class is the same as @var{LUT}. +## @end deftypefn + +## Author: Josep Mones i Teixidor + +function B = uintlut(A, LUT) + if (nargin != 2) + usage("B = uintlut(A, LUT)"); + endif + + ## We convert indexing array A to double since even CVS version of + ## Octave is unable to use non-double arrays as indexing types. This + ## won't be needed in the future eventually. + B=LUT(double(A)); +endfunction + +%!demo +%! uintlut(uint8([1,2,3,4]),uint8([255:-1:0])); +%! % Returns a uint8 array [255,254,253,252] + +%!assert(uintlut(uint8([1,2,3,4]),uint8([255:-1:0])), uint8([255:-1:252])); +%!assert(uintlut(uint16([1,2,3,4]),uint16([255:-1:0])), uint16([255:-1:252])); +%!assert(uintlut(uint32([1,2,3,4]),uint32([255:-1:0])), uint32([255:-1:252])); +%!assert(uintlut(uint64([1,2,3,4]),uint64([255:-1:0])), uint64([255:-1:252])); + +% +% $Log$ +% Revision 1.2 2007/03/23 16:14:38 adb014 +% Update the FSF address +% +% Revision 1.1 2006/08/20 12:59:36 hauberg +% Changed the structure to match the package system +% +% Revision 1.2 2004/08/11 15:04:59 pkienzle +% Convert dos line endings to unix line endings +% +% Revision 1.1 2004/08/08 21:20:25 jmones +% uintlut and padarray functions added +% +%