view histogram/accumhist.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 H=accumhist(I,W,D)
% accumhist - Just like accumarray but filters out rows with nans or infs
%
% accumhist ::
%    [[N,E]->(natural|nan|inf|-inf)] ~'N rows of E-dim array indices',
%    ([[N]->real] | real) ~'the weights associated with each row',
%    D:[[E]->natural]  ~'the size of the array to return'
% -> [[D]].
%
% Note that unlike with accumarray and other Matlab builtins, the size 
% argument D can be a single element, eg [M], indicating that a vector
% is desired. accumarry would require [M 1].

H = accumarray(I(all(isfinite(I),2),:),W,tosize(D));