-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.m
More file actions
29 lines (24 loc) · 644 Bytes
/
bin.m
File metadata and controls
29 lines (24 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function C = bin(A,b,isOneDimensional)
if nargin < 3
isOneDimensional = false;
end
if isOneDimensional && isvector(A)
A = A(:);
end
sizeA = size(A);
C = zeros([sizeA(1:(2-isOneDimensional))/b sizeA((3-isOneDimensional):end)]);
n = b^(2-isOneDimensional);
if ndims(A) <= 2
nFrames = 1;
else
nFrames = prod(sizeA(3:end));
end
c = (b-(b-1)*isOneDimensional);
for kk = 1:nFrames
for ii = 1:b
for jj = 1:c
C(:,:,kk) = C(:,:,kk) + double(A(ii:b:end,jj:c:end,kk))/n;
end
end
end
end