Blame view

old/rtsMaskReconstruct.m 825 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
23
24
25
26
27
28
29
30
31
32
33
34
  function I = rtsMaskReconstruct(data, mask, fillVal)
  
  %This function reconstructs an array of data created from a mask
  % data = a VxD matrix, where D = positions and V = values
  % mask = a binary image with D nonzero values
  
  %compute the number of values at each pixel
  nV = size(data, 1);
  
  %allocate space
  nX = size(mask, 1);
  nY = size(mask, 2);
  I = ones(nV, nX*nY) * fillVal;
  
  d=1;
  %for each position
  for p = 1:nX*nY
      
      %if the mask value at the position is true, copy values
      if(mask(p) && d < size(data, 2))
          I(:, p) = data(:, d);
          
          %increment the data pointer
          d = d + 1;
          
      %if the mask value at the position is zero, set all values to zero
      else
          I(:, p) = ones(nV, 1) * fillVal;
      end 
      
  end
  
  %reshape the array into an image
  I = reshape(I', [nX nY nV]);