parameters: (self, image)
return_statement: return np.stack(list(self.__processed_image_seq))
docstring: Return preprocessed screen images from Atari 2600 games.
docstring_summary: Return preprocessed screen images from Atari 2600 games.
docstring_tokens: Return preprocessed screen images from Atari 2600 games .
function: def preprocess(self, image):
          """Return preprocessed screen images from Atari 2600 games."""
          if image.shape != self._input_shape:
              raise ValueError(
                  'Expecting image in shape {0} but get {1}\n'.format(
                      self._input_shape, image.shape))
  
          # Take the maximum value for each pixel over the current frame and the
          # previous one.
          im = Image.fromarray(
              np.maximum(image, self.__previous_raw_image), mode='RGB')
  
          # Extract luminance band.
          im = im.convert('YCbCr').split()[0]
  
          # Scale to 84 x 84
          im = im.resize((84, 84), Image.BILINEAR)
  
          self.__processed_image_seq.append(np.array(im))
          self.__previous_raw_image = image
  
          return np.stack(list(self.__processed_image_seq))
function_tokens: def preprocess ( self , image ) : if image . shape != self . _input_shape : raise ValueError ( 'Expecting image in shape {0} but get {1}\n' . format ( self . _input_shape , image . shape ) ) # Take the maximum value for each pixel over the current frame and the # previous one. im = Image . fromarray ( np . maximum ( image , self . __previous_raw_image ) , mode = 'RGB' ) # Extract luminance band. im = im . convert ( 'YCbCr' ) . split ( ) [ 0 ] # Scale to 84 x 84 im = im . resize ( ( 84 , 84 ) , Image . BILINEAR ) self . __processed_image_seq . append ( np . array ( im ) ) self . __previous_raw_image = image return np . stack ( list ( self . __processed_image_seq ) )