Mercurial > hg > ishara
annotate 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 |
rev | line source |
---|---|
samer@57 | 1 function z=plothist_lin(h,m) |
samer@57 | 2 % plothist_lin - Plot histogram assuming triangular kernel (linear interpolation) |
samer@57 | 3 % |
samer@57 | 4 % plothist_lin :: [[N]->natural], dmap(N-1) -> handle. |
samer@57 | 5 |
samer@57 | 6 e=edges(m); |
samer@57 | 7 e=[2*e(1)-e(2),e,2*e(end)-e(end-1)]; |
samer@57 | 8 |
samer@57 | 9 z=ezplot(@pdf,[e(1),e(end)]); |
samer@57 | 10 |
samer@57 | 11 function p=pdf(x) |
samer@57 | 12 % if ~isscalar(x), error('must be scalar'); end |
samer@57 | 13 % j=find(x>e(1:end-2) & x<e(3:end)); |
samer@57 | 14 p=0; |
samer@57 | 15 for i=1:length(h) %j |
samer@57 | 16 p=p+triangle(e(i:i+2),h(i)); |
samer@57 | 17 end |
samer@57 | 18 |
samer@57 | 19 function y=triangle(a,h) |
samer@57 | 20 y=zeros(size(x)); |
samer@57 | 21 I1=(x>a(1) & x<=a(2)); |
samer@57 | 22 I2=(x>a(2) & x<a(3)); |
samer@57 | 23 y(I1)=h*((x(I1)-a(1))/(a(2)-a(1))); |
samer@57 | 24 y(I2)=h*((x(I2)-a(3))/(a(2)-a(3))); |
samer@57 | 25 end |
samer@57 | 26 end |
samer@57 | 27 end |
samer@57 | 28 |