Skip to content

Instantly share code, notes, and snippets.

@emoen
Created February 4, 2022 12:27
Show Gist options
  • Save emoen/afe8f81f2b29903b303357f73583ca1d to your computer and use it in GitHub Desktop.
Save emoen/afe8f81f2b29903b303357f73583ca1d to your computer and use it in GitHub Desktop.
pil_img1 = load_img('/gpfs/gpfs0/deep/data/Savannah_Professional_Practice2021_08_12_2021/CodOtholiths-MachineLearning/Savannah_Professional_Practice/2013/70174/Nr06_age09/IMG_0034.JPG',target_size=(CONFIG.val_img_size, CONFIG.val_img_size))
pil_img2 = load_img('/gpfs/gpfs0/deep/data/Savannah_Professional_Practice2021_08_12_2021/CodOtholiths-MachineLearning/Savannah_Professional_Practice/2013/70174/Nr06_age09/IMG_0036.JPG',target_size=(CONFIG.val_img_size, CONFIG.val_img_size))
pil_img3 = load_img('/gpfs/gpfs0/deep/data/Savannah_Professional_Practice2021_08_12_2021/CodOtholiths-MachineLearning/Savannah_Professional_Practice/2013/70174/Nr06_age09/IMG_0032.JPG',target_size=(CONFIG.val_img_size, CONFIG.val_img_size))
array_img = img_to_array(pil_img1, data_format=CONFIG.CHANNELS)
array_img2 = img_to_array(pil_img2, data_format=CONFIG.CHANNELS)
array_img3 = img_to_array(pil_img3, data_format=CONFIG.CHANNELS)
array_img_6D = np.append(array_img, array_img2, axis=0)
array_img_9D = np.append(array_img_6D, array_img3, axis=0)
channel1 = array_img_9D[0:9:3,:,:]
channel2 = array_img_9D[1:9:3,:,:]
channel3 = array_img_9D[2:9:3,:,:]
channel1 = np.mean(channel1, axis=0 )
channel2 = np.mean(channel2, axis=0 )
channel3 = np.mean(channel3, axis=0 )
d3_img = np.stack((channel1, channel2, channel3), axis=0)
fig = plt.figure(figsize=(2, 2))
fig.add_subplot(2, 2, 1)
plt.imshow(array_img.transpose(2,1,0)*(1.0/255))
plt.xticks([])
plt.yticks([])
fig.add_subplot(2, 2, 2)
plt.imshow(array_img2.transpose(2,1,0)*(1.0/255))
plt.xticks([])
plt.yticks([])
fig.add_subplot(2, 2, 3)
plt.imshow(array_img3.transpose(2,1,0)*(1.0/255))
plt.xticks([])
plt.yticks([])
fig.add_subplot(2, 2, 4)
plt.imshow( d3_img.transpose(2,1,0) *(1.0/255) )
plt.xticks([])
plt.yticks([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment