-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetPlanes.m
44 lines (38 loc) · 1.16 KB
/
getPlanes.m
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [p1, p2, p3] = getPlanes(allplanes, whichplane)
% [p1, p2, p3] = getPlanes(allplanes, whichplane)
%
% Separate an image matrix which has 3 planes in to 3 individual matrices.
% allplanes -- concatenated image planes, in the form [plane1 plane2 plane3].
% whichplane -- specifies which planes to return. Defaults to [1 2 3]
% (get all 3 planes, and return in p1, p2, p3).
%
% The separated image planes are returned in the order given by whichplane.
%
% If allplanes is one number, take that as the number of columns for
% allplanes, and return the column indices of the separate planes.
% (for example, if allplanes = 6, return p1=[1 2], p2=[3 4], p3=[5 6]);
%
% Xuemei Zhang
% Last Modified 1/28/96
if (nargin==1)
whichplane = [1 2 3];
end
[m,n] = size(allplanes);
if (m*n==1)
n = round(allplanes/3);
allplanes = 1:allplanes;
else
n = round(n/3);
end
if (n*3 ~= size(allplanes,2))
error('Input image allplanes is not the correct size.');
end
a = (whichplane-1) * n + 1; % start indices
z = whichplane * n; % end indices
p1 = allplanes(:, a(1):z(1));
if (nargout>1)
p2 = allplanes(:, a(2):z(2));
end
if (nargout>2)
p3 = allplanes(:, a(3):z(3));
end