def mask_image_stack(input_image_stack, input_seg_seq):
    background = [mask == 0 for mask in input_seg_seq]
    background = reduce(lambda m1, m2: m1 & m2, background)
    # If masks are RGB, assume all channels to be the same. Reduce to the first.
    if background.ndim == 3 and background.shape[2] > 1:
        background = np.expand_dims(background[:, :, 0], axis=2)
    elif background.ndim == 2:  # Expand.
        background = np.expand_dism(background, axis=2)
    # background is now of shape (H, W, 1).
    background_stack = np.tile(background, [1, 1, input_image_stack.shape[3]])
    return np.multiply(input_image_stack, background_stack)
Example #2
0
def mask_image_stack(input_image_stack, input_seg_seq):
    """Masks out moving image contents by using the segmentation masks provided.
  This can lead to better odometry accuracy for motion models, but is optional
  to use. Is only called if use_masks is enabled.
  Args:
    input_image_stack: The input image stack of shape (1, H, W, seq_length).
    input_seg_seq: List of segmentation masks with seq_length elements of shape
                   (H, W, C) for some number of channels C.
  Returns:
    Input image stack with detections provided by segmentation mask removed.
  """
    background = [mask == 0 for mask in input_seg_seq]
    background = reduce(lambda m1, m2: m1 & m2, background)
    # If masks are RGB, assume all channels to be the same. Reduce to the first.
    if background.ndim == 3 and background.shape[2] > 1:
        background = np.expand_dims(background[:, :, 0], axis=2)
    elif background.ndim == 2:  # Expand.
        background = np.expand_dism(background, axis=2)
    # background is now of shape (H, W, 1).
    background_stack = np.tile(background, [1, 1, input_image_stack.shape[3]])
    return np.multiply(input_image_stack, background_stack)
Example #3
0
def mask_image_stack(input_image_stack, input_seg_seq):
  """Masks out moving image contents by using the segmentation masks provided.

  This can lead to better odometry accuracy for motion models, but is optional
  to use. Is only called if use_masks is enabled.
  Args:
    input_image_stack: The input image stack of shape (1, H, W, seq_length).
    input_seg_seq: List of segmentation masks with seq_length elements of shape
                   (H, W, C) for some number of channels C.

  Returns:
    Input image stack with detections provided by segmentation mask removed.
  """
  background = [mask == 0 for mask in input_seg_seq]
  background = reduce(lambda m1, m2: m1 & m2, background)
  # If masks are RGB, assume all channels to be the same. Reduce to the first.
  if background.ndim == 3 and background.shape[2] > 1:
    background = np.expand_dims(background[:, :, 0], axis=2)
  elif background.ndim == 2:  # Expand.
    background = np.expand_dism(background, axis=2)
  # background is now of shape (H, W, 1).
  background_stack = np.tile(background, [1, 1, input_image_stack.shape[3]])
  return np.multiply(input_image_stack, background_stack)