code: def create_blurred_image(
      full_img: np.ndarray,
      pixel_mask: np.ndarray,
      method: str = "linear",
  ) -> np.ndarray:
      """Creates a blurred (interpolated) image.
  
      Args:
        full_img: an original input image that should be used as the source for
          interpolation. The image should be represented by a numpy array with
          dimensions [H, W, C] or [H, W].
        pixel_mask: a binary mask, where 'True' values represent pixels that should
          be retrieved from the original image as the source for the interpolation
          and 'False' values represent pixels, which values should be found. The
          method always sets the corner pixels of the mask to True. The mask
          dimensions should be [H, W].
        method: the method to use for the interpolation. The 'linear' method is
          recommended. The alternative value is 'nearest'.
  
        Returns:
          A numpy array that encodes the blurred image with exactly the same
          dimensions and type as `full_img`.
      """
      data_type = full_img.dtype
      has_color_channel = full_img.ndim > 2
      if not has_color_channel:
          full_img = np.expand_dims(full_img, axis=2)
      channels = full_img.shape[2]
  
      # Always include corners.
      pixel_mask = pixel_mask.copy()
      height = pixel_mask.shape[0]
      width = pixel_mask.shape[1]
      pixel_mask[
          [0, 0, height - 1, height - 1], [0, width - 1, 0, width - 1]
      ] = True
  
      mean_color = np.mean(full_img, axis=(0, 1))
  
      # If the mask consists of all pixels set to True then return the original
      # image.
      if np.all(pixel_mask):
          return full_img
  
      blurred_img = full_img * np.expand_dims(
          pixel_mask, axis=2
      ).astype(np.float32)
  
      # Interpolate the unmasked values of the image pixels.
      for channel in range(channels):
          data_points = np.argwhere(pixel_mask > 0)
          data_values = full_img[:, :, channel][tuple(data_points.T)]
          unknown_points = np.argwhere(pixel_mask == 0)
          interpolated_values = interpolate.griddata(
              np.array(data_points),
              np.array(data_values),
              np.array(unknown_points),
              method=method,
              fill_value=mean_color[channel],
          )
          blurred_img[:, :, channel][
              tuple(unknown_points.T)
          ] = interpolated_values
  
      if not has_color_channel:
          blurred_img = blurred_img[:, :, 0]
  
      if issubclass(data_type.type, np.integer):
          blurred_img = np.round(blurred_img)
  
      return blurred_img.astype(data_type)
  
file_path: saliency/saliency/metrics/pic.py
imports: import io
  import numpy
  import os
  from PIL import Image
  from scipy import interpolate
  from typing import Callable, List, NamedTuple, Optional, Sequence, Tuple
label_desc: Use image node_id 1 for calling a global function with example usage: create_blurred_image(full_img, pixel_mask, method) and returns: blurred_img, full_img