Closed changwei0314 closed 10 months ago
Hi,
Here is the code snippet that you can use
imgs_pil_o = [transforms.ToPILImage()(img_o) for img_o in imgs_o]
imgs_pil_w = [transforms.ToPILImage()(img_w) for img_w in imgs_w]
diffs = [np.abs(np.asarray(img_o).astype(int) - np.asarray(img_w).astype(int)) *10 for img_o, img_w in zip(imgs_pil_o, imgs_pil_w)]
diffs = [Image.fromarray(diff.astype(np.uint8)) for diff in diffs]
for ii in range(len(imgs_pil_o)):
print('PSNR w, o:', peak_signal_noise_ratio( np.array(imgs_pil_w[ii]), np.array(imgs_pil_o[ii]) ) )
plt.figure(figsize=(20, 20))
plt.subplot(1, 3, 1)
plt.imshow(imgs_pil_w[ii])
plt.axis('off')
plt.grid(False)
plt.subplot(1, 3, 2)
plt.imshow(imgs_pil_o[ii])
plt.axis('off')
plt.grid(False)
plt.subplot(1, 3, 3)
plt.imshow(diffs[ii])
plt.axis('off')
plt.grid(False)
plt.show()
# save everything
save_dir = "/private/home/pfz/_images/"
for ii in range(len(imgs_pil_o)):
imgs_pil_o[ii].save(os.path.join(save_dir, imgs_paths[ii]))
imgs_pil_w[ii].save(os.path.join(save_dir, imgs_paths[ii].replace(".png", "_w.png")))
diffs[ii].save(os.path.join(save_dir, imgs_paths[ii].replace(".png", "_diff.png")))
Closing, no activity
Hi, thanks for your amazing work!
Could you show how to implement the pixel-wise difference part? I'm confused about how to get the pixel-wise difference image (like Figure 6). Thanks!