Created
July 19, 2017 04:25
-
-
Save TomHortons/3aec684789d64cc0631ad5834fa67222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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