Skip to content

Instantly share code, notes, and snippets.

@shayaf84
Last active November 20, 2021 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shayaf84/68fbdbb1249825173d35b560f7a52767 to your computer and use it in GitHub Desktop.
Save shayaf84/68fbdbb1249825173d35b560f7a52767 to your computer and use it in GitHub Desktop.
def interpolation(baseline, image, alpha):
#Interpolates images by computing the difference between its pixel values
#and the baseline (all zeroes)
#From there, construct a new tensor containing the baseline and interpolated
#images, which are the picture values multiplied by the linear relationship.
alphaTensor = alpha[:, tf.newaxis, tf.newaxis, tf.newaxis]
baselineTensor = tf.expand_dims(baseline, axis=0)
inputTensor = tf.expand_dims(image, axis=0)
diff = inputTensor - baselineTensor
images = baselineTensor + alphaTensor * diff
return images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment