annotate general/arrutils/accumhist.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents a5b8bd686246
children
rev   line source
samer@54 1 function H=accumhist(I,W,D)
samer@54 2 % accumhist - Just like accumarray but filters out rows with nans or infs
samer@54 3 %
samer@54 4 % accumhist ::
samer@54 5 % [[N,E]->(natural|nan|inf|-inf)] ~'N rows of E-dim array indices',
samer@54 6 % ([[N]->real] | real) ~'the weights associated with each row',
samer@54 7 % D:[[E]->natural] ~'the size of the array to return'
samer@54 8 % -> [[D]].
samer@54 9 %
samer@54 10 % Note that unlike with accumarray and other Matlab builtins, the size
samer@54 11 % argument D can be a single element, eg [M], indicating that a vector
samer@54 12 % is desired. accumarry would require [M 1].
samer@54 13
samer@55 14 K=all(isfinite(I),2);
samer@56 15 if ~isscalar(W), W=W(K); end
samer@56 16 H = accumarray(I(K,:),W,tosize(D));
samer@54 17