Mercurial > hg > ishara
view general/discretise/intmap.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | e44f49929e56 |
children |
line wrap: on
line source
function M=intmap(min,max) % intmap - Discretisation map for integers (ie alread discrete) % % intmap :: integer~'min value', integer~'max value' -> dmap(N). % % Maps integers to natural numbers, saves on multiplications and % roundings as performed by the real->natural maps. N=max-min+1; off=min-1; M=dmap(N,@map,@revmap); function I=map(X) I=X-off; I(I<1)=-inf; I(I>N)=inf; end function X=revmap(I) I=shiftdim(shiftdim(I),-1); X1=off+I-0.5; X2=off+I+0.5; X=cat(1,X1,X2); end end