-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmask_combine.m
executable file
·41 lines (33 loc) · 1.21 KB
/
mask_combine.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
function Res=mask_combine(MaskIm,CombFun)
% Combine all the Mask images in a single MASK object array.
% Package: @MASK
% Description: Combine all the Mask images in a single MASK object array.
% Input : - MASK object.
% - Combine function: @bitand, @bitor. Default is @bitor.
% Output : - A Mask object with a single elemnt containing the combination
% of all the elements in the input MASK object.
% License: GNU general public license version 3
% Tested : Matlab R2015b
% By : Eran O. Ofek Apr 2016
% URL : http://weizmann.ac.il/home/eofek/matlab/
% Example: Res=mask_combine(MaskIm)
% Reliable: 2
%--------------------------------------------------------------------------
MaskField = 'Mask';
MaskDicField = 'MaskDic';
if (nargin<2),
CombFun = @bitor;
end
Nmask = numel(MaskIm);
Res = MASK;
for Imask=1:1:Nmask,
if (isempty(Res.(MaskField))),
% Res was empty -
Res.(MaskField) = MaskIm(Imask).(MaskField);
Res.(MaskDicField) = MaskIm(Imask).(MaskDicField);
else
if (~isempty(MaskIm(Imask).(MaskField))),
Res.(MaskField) = CombFun(Res.(MaskField),MaskIm(Imask).(MaskField));
end
end
end