Mercurial > hg > ishara
view general/discretise/binmap.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
% binmap - linear discretisation map from bin centres % % binmap :: real~'first bin centre', real~'last bin centre', N:natural~'num bins'->dmap(N). function M=binmap(min,max,N) dx=(max-min)/(N-1); rdx=1/dx; M=dmap(N,@map,@revmap); function I=map(X) I=1+round(rdx*(X-min)); I(I<1)=-inf; I(I>N)=inf; end function X=revmap(I) I=shiftdim(shiftdim(I),-1); X1=min+(I-1.5)*dx; X2=min+(I-0.5)*dx; X=cat(1,X1,X2); end end