Skip to content

Instantly share code, notes, and snippets.

@vihar
Created January 13, 2019 15:21
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 vihar/a4099a4bfb8468e61a5723f47660d6db to your computer and use it in GitHub Desktop.
Save vihar/a4099a4bfb8468e61a5723f47660d6db to your computer and use it in GitHub Desktop.
img = np.squeeze(images[7])
fig = plt.figure(figsize = (12,12))
ax = fig.add_subplot(111)
ax.imshow(img, cmap='gray')
width, height = img.shape
thresh = img.max()/2.5
for x in range(width):
for y in range(height):
val = round(img[x][y],2) if img[x][y] !=0 else 0
ax.annotate(str(val), xy=(y,x),
color='white' if img[x][y]<thresh else 'black')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment