annotate general/arrutils/revdims.m @ 61:eff6bddf82e3
tip
Finally implemented perceptual brightness thing.
author |
samer |
date |
Sun, 11 Oct 2015 10:20:42 +0100 |
parents |
e44f49929e56 |
children |
|
rev |
line source |
samer@4
|
1 function B=revdims(A,N)
|
samer@4
|
2 % revdims - reverse N dimensions of a multidimensional array
|
samer@4
|
3 %
|
samer@4
|
4 % revdims :: [[D:[[1,M]]]], N:natural -> [[D2:[[1,M]]]].
|
samer@4
|
5 % revdims :: [[D:[[1,M]]]] -> [[D2:[[1,M]]]].
|
samer@4
|
6 %
|
samer@4
|
7 % This takes an array of size [D(1:N) DX]
|
samer@4
|
8 % and returns an array of size [D(N:-1:1) DX]
|
samer@4
|
9 % where DX are the rest of the dimensions after the Nth and are
|
samer@4
|
10 % unaffected. N defaults to the number of dimensions disregarding
|
samer@4
|
11 % trailing singletons, ie numdims(A)==length(size1(A))
|
samer@4
|
12
|
samer@4
|
13 if nargin<2, N=numdims(A); end
|
samer@4
|
14
|
samer@4
|
15 ND=max(N,2);
|
samer@4
|
16 DD=1:ND;
|
samer@4
|
17 DD(1:N)=fliplr(DD(1:N));
|
samer@4
|
18 B=permute(A,DD);
|