Blame view

old/rtsRandomizeMask.m 368 Bytes
8be1ab93   David Mayerich   initial commit of...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  function R = rtsRandomizeMask(mask, N)
  
  %error checking
  if N > nnz(mask)
      N = nnz(mask);
  end
  
  if N < 0
      N = 0;
  end
  
  %get the indices of all nonzero values in the mask
  ind = find(mask);
  
  %randomize the indices
  rind = ind(randperm(size(ind, 1)));
  
  %create the new randomized mask (random subset of the old mask)
  R = zeros(size(mask));
  R(rind(1:N)) = 1;
  
  R = R > 0;