1 | function H = histmarg(H, dims) |
---|
2 | % HISTMARG Marginal of histogram |
---|
3 | % H = HISTMARG(H, DIMS) marginalizes the historgram HISTMARG w.r.t |
---|
4 | % the dimensions DIM. This is done by summing out all dimensions |
---|
5 | % not listed in DIM and deleting them. |
---|
6 | % |
---|
7 | % REMARK. If DIMS lists only one dimension, the returned H is a |
---|
8 | % column vector. This way of deleting dimensions is not always |
---|
9 | % consistent with the SQUEEZE function. |
---|
10 | |
---|
11 | % AUTORIGHTS |
---|
12 | % Copyright (C) 2006 Andrea Vedaldi |
---|
13 | % |
---|
14 | % This file is part of VLUtil. |
---|
15 | % |
---|
16 | % VLUtil is free software; you can redistribute it and/or modify |
---|
17 | % it under the terms of the GNU General Public License as published by |
---|
18 | % the Free Software Foundation; either version 2, or (at your option) |
---|
19 | % any later version. |
---|
20 | % |
---|
21 | % This program is distributed in the hope that it will be useful, |
---|
22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
24 | % GNU General Public License for more details. |
---|
25 | % |
---|
26 | % You should have received a copy of the GNU General Public License |
---|
27 | % along with this program; if not, write to the Free Software Foundation, |
---|
28 | % Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
29 | |
---|
30 | sz = size(H) ; |
---|
31 | |
---|
32 | for d=setdiff( 1:length(sz), dims(:) ) |
---|
33 | H = sum(H, d) ; |
---|
34 | end |
---|
35 | |
---|
36 | % Squeeze out marginalized dimensions |
---|
37 | sz = sz(dims(:)) ; |
---|
38 | sz = [sz ones(1,2-length(dims(:)))] ; |
---|
39 | H = reshape(H, sz) ; |
---|