-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmask4src.m
executable file
·42 lines (38 loc) · 1.46 KB
/
mask4src.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
function Flag=mask4src(Mask,CellInd,Operation)
% Return bit mask for specific pixels in images (sources).
% Package: @MASK
% Description: Return bit mask for specific pixels in images (sources).
% Input : - A MASK object with a single element.
% - Either a vector of indices or a cell array of vectors of
% indices. For each vector of indices the and/or/xor over all
% mask values corresponding to the indices will be calculated.
% - Operation: @Util.array.bitor_array, @Util.array.bitand_array
% Default is @Util.array.bitor_array.
% Output : - A column vector of bit masks. An element per source
% (i.e., element in the cell array).
% License: GNU general public license version 3
% Tested : Matlab R2015b
% By : Eran O. Ofek Jun 2016
% URL : http://weizmann.ac.il/home/eofek/matlab/
% Example: CI = ImUtil.Im.find_within_radius_cell(Size,X,Y,Radius,Circle)
% Flag=mask4src(Mask,CI);
% Reliable: 2
%--------------------------------------------------------------------------
MaskField = 'Mask';
if (nargin==2)
Operation = @Util.array.bitor_array;
end
if (numel(Mask)>1)
error('MASK element must have a single element');
end
if (~iscell(CellInd))
CellInd = {CellInd};
end
Ncell = numel(CellInd);
Flag = zeros(Ncell,1);
for Icell=1:1:Ncell
if (~isempty(Mask.(MaskField)))
Vec = Mask.(MaskField)(CellInd{Icell});
Flag(Icell) = Operation(Vec(:),1);
end
end