parameters: (im, new_dims, interp_order=1)
return_statement: return resized_im.astype(np.float32)
docstring: Resize an image array with interpolation.
  
      Parameters
      ----------
      im : (H x W x K) ndarray
      new_dims : (height, width) tuple of new dimensions.
      interp_order : interpolation order, default is linear.
  
      Returns
      -------
      im : resized ndarray with shape (new_dims[0], new_dims[1], K)
docstring_summary: Resize an image array with interpolation.
docstring_tokens: Resize an image array with interpolation .
function: def resize_image(im, new_dims, interp_order=1):
      """
      Resize an image array with interpolation.
  
      Parameters
      ----------
      im : (H x W x K) ndarray
      new_dims : (height, width) tuple of new dimensions.
      interp_order : interpolation order, default is linear.
  
      Returns
      -------
      im : resized ndarray with shape (new_dims[0], new_dims[1], K)
      """
      if im.shape[-1] == 1 or im.shape[-1] == 3:
          im_min, im_max = im.min(), im.max()
          if im_max > im_min:
              # skimage is fast but only understands {1,3} channel images
              # in [0, 1].
              im_std = (im - im_min) / (im_max - im_min)
              resized_std = resize(im_std, new_dims, order=interp_order)
              resized_im = resized_std * (im_max - im_min) + im_min
          else:
              # the image is a constant -- avoid divide by 0
              ret = np.empty((new_dims[0], new_dims[1], im.shape[-1]),
                             dtype=np.float32)
              ret.fill(im_min)
              return ret
      else:
          # ndimage interpolates anything but more slowly.
          scale = tuple(np.array(new_dims, dtype=float) / np.array(im.shape[:2]))
          resized_im = zoom(im, scale + (1,), order=interp_order)
      return resized_im.astype(np.float32)
function_tokens: def resize_image ( im , new_dims , interp_order = 1 ) : if im . shape [ - 1 ] == 1 or im . shape [ - 1 ] == 3 : im_min , im_max = im . min ( ) , im . max ( ) if im_max > im_min : # skimage is fast but only understands {1,3} channel images # in [0, 1]. im_std = ( im - im_min ) / ( im_max - im_min ) resized_std = resize ( im_std , new_dims , order = interp_order ) resized_im = resized_std * ( im_max - im_min ) + im_min else : # the image is a constant -- avoid divide by 0 ret = np . empty ( ( new_dims [ 0 ] , new_dims [ 1 ] , im . shape [ - 1 ] ) , dtype = np . float32 ) ret . fill ( im_min ) return ret else : # ndimage interpolates anything but more slowly. scale = tuple ( np . array ( new_dims , dtype = float ) / np . array ( im . shape [ : 2 ] ) ) resized_im = zoom ( im , scale + ( 1 , ) , order = interp_order ) return resized_im . astype ( np . float32 )