Skip to content

Instantly share code, notes, and snippets.

@TomHortons
Created July 19, 2017 04:25
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 TomHortons/3aec684789d64cc0631ad5834fa67222 to your computer and use it in GitHub Desktop.
Save TomHortons/3aec684789d64cc0631ad5834fa67222 to your computer and use it in GitHub Desktop.
mask = np.zeros_like(sq_dists, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# upper triangle of matrix set to np.nan
sq_dists[np.triu_indices_from(mask)] = np.nan
sq_dists[0, 0] = np.nan
fig = plt.figure(figsize=(12,8))
# maximally dissimilar image
ax = fig.add_subplot(1,2,1)
maximally_dissimilar_image_idx = np.nanargmax(np.nanmean(sq_dists, axis=1))
plt.imshow(plt.imread(image_paths[maximally_dissimilar_image_idx]))
plt.title('maximally dissimilar')
# maximally similar image
ax = fig.add_subplot(1,2,2)
maximally_similar_image_idx = np.nanargmin(np.nanmean(sq_dists, axis=1))
plt.imshow(plt.imread(image_paths[maximally_similar_image_idx]))
plt.title('maximally similar')
# # now compute the mean image
#ax = fig.add_subplot(1,3,3)
#mean_img = gray_imgs_mat.mean(axis=0).reshape(rescaled_dim, rescaled_dim, 3)
#plt.imshow(cv2.normalize(mean_img, None, 0.0, 1.0, cv2.NORM_MINMAX))
#plt.title('mean image')
/opt/conda/lib/python3.6/site-packages/numpy/lib/nanfunctions.py:703: RuntimeWarning:
Mean of empty slice
/opt/conda/lib/python3.6/site-packages/numpy/lib/nanfunctions.py:703: RuntimeWarning:
Mean of empty slice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment