Mercurial > hg > ishara
view histogram/plothist_lin.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | ce9021da6ce2 |
children |
line wrap: on
line source
function z=plothist_lin(h,m) % plothist_lin - Plot histogram assuming triangular kernel (linear interpolation) % % plothist_lin :: [[N]->natural], dmap(N-1) -> handle. e=edges(m); e=[2*e(1)-e(2),e,2*e(end)-e(end-1)]; z=ezplot(@pdf,[e(1),e(end)]); function p=pdf(x) % if ~isscalar(x), error('must be scalar'); end % j=find(x>e(1:end-2) & x<e(3:end)); p=0; for i=1:length(h) %j p=p+triangle(e(i:i+2),h(i)); end function y=triangle(a,h) y=zeros(size(x)); I1=(x>a(1) & x<=a(2)); I2=(x>a(2) & x<a(3)); y(I1)=h*((x(I1)-a(1))/(a(2)-a(1))); y(I2)=h*((x(I2)-a(3))/(a(2)-a(3))); end end end