show_mscn.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from ipfml import image_processing
  2. from PIL import Image
  3. import numpy as np
  4. from ipfml import metrics
  5. from skimage import color
  6. import cv2
  7. path_noisy = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_00050.png'
  8. path_threshold = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_00400.png'
  9. path_ref = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_01200.png'
  10. path_list = [path_noisy, path_threshold, path_ref]
  11. labels = ['noisy', 'threshold', 'reference']
  12. for id, p in enumerate(path_list):
  13. img = Image.open(p)
  14. img.show()
  15. # Revisited MSCN
  16. current_img_mscn = image_processing.rgb_to_mscn(img)
  17. current_img_output = current_img_mscn.astype('uint8')
  18. img_mscn_pil = Image.fromarray(current_img_output.astype('uint8'), 'L')
  19. img_mscn_pil.show()
  20. img_mscn_pil.save('/home/jbuisine/Downloads/' + labels[id] + '_revisited.png')
  21. # MSCN
  22. img_grey = np.array(color.rgb2gray(np.asarray(img))*255, 'uint8')
  23. img_mscn_in_grey = np.array(image_processing.normalize_2D_arr(image_processing.calculate_mscn_coefficients(img_grey, 7))*255, 'uint8')
  24. img_mscn_pil = Image.fromarray(img_mscn_in_grey.astype('uint8'), 'L')
  25. img_mscn_pil.show()
  26. img_mscn_pil.save('/home/jbuisine/Downloads/' + labels[id] + '_mscn.png')