display_bits_values.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. low_bits_2_svd_values = []
  8. low_bits_3_svd_values = []
  9. low_bits_4_svd_values = []
  10. low_bits_5_svd_values = []
  11. low_bits_6_svd_values = []
  12. low_bits_7_svd_values = []
  13. def open_and_display(path):
  14. img = Image.open(path)
  15. block_used = np.array(img)
  16. # computation of low bits parts 2 bits
  17. low_bits_block = image_processing.rgb_to_LAB_L_low_bits(block_used, 3)
  18. low_bits_svd = metrics.get_SVD_s(low_bits_block)
  19. low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
  20. low_bits_2_svd_values.append(low_bits_svd)
  21. # computation of low bits parts 3 bits
  22. low_bits_block = image_processing.rgb_to_LAB_L_low_bits(block_used, 7)
  23. low_bits_svd = metrics.get_SVD_s(low_bits_block)
  24. low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
  25. low_bits_3_svd_values.append(low_bits_svd)
  26. # computation of low bits parts 4 bits
  27. low_bits_block = image_processing.rgb_to_LAB_L_low_bits(block_used)
  28. low_bits_svd = metrics.get_SVD_s(low_bits_block)
  29. low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
  30. low_bits_4_svd_values.append(low_bits_svd)
  31. # computation of low bits parts 5 bits
  32. low_bits_block = image_processing.rgb_to_LAB_L_low_bits(block_used, 31)
  33. low_bits_svd = metrics.get_SVD_s(low_bits_block)
  34. low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
  35. low_bits_5_svd_values.append(low_bits_svd)
  36. # computation of low bits parts 6 bits
  37. low_bits_block = image_processing.rgb_to_LAB_L_low_bits(block_used, 63)
  38. low_bits_svd = metrics.get_SVD_s(low_bits_block)
  39. low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
  40. low_bits_6_svd_values.append(low_bits_svd)
  41. # computation of low bits parts 7 bits
  42. low_bits_block = image_processing.rgb_to_LAB_L_low_bits(block_used, 127)
  43. low_bits_svd = metrics.get_SVD_s(low_bits_block)
  44. low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
  45. low_bits_7_svd_values.append(low_bits_svd)
  46. path_noisy = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_00050.png'
  47. path_threshold = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_00400.png'
  48. path_ref = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_01200.png'
  49. path_list = [path_noisy, path_threshold, path_ref]
  50. for p in path_list:
  51. open_and_display(p)
  52. import matplotlib.pyplot as plt
  53. # SVD
  54. # make a little extra space between the subplots
  55. plt.plot(low_bits_2_svd_values[0], label='Noisy')
  56. plt.plot(low_bits_2_svd_values[1], label='Threshold')
  57. plt.plot(low_bits_2_svd_values[2], label='Reference')
  58. plt.ylabel('Low 2 bits SVD')
  59. plt.xlabel('Vector features')
  60. plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
  61. plt.ylim(0, 0.1)
  62. plt.show()
  63. plt.plot(low_bits_3_svd_values[0], label='Noisy')
  64. plt.plot(low_bits_3_svd_values[1], label='Threshold')
  65. plt.plot(low_bits_3_svd_values[2], label='Reference')
  66. plt.ylabel('Low 3 bits SVD')
  67. plt.xlabel('Vector features')
  68. plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
  69. plt.ylim(0, 0.1)
  70. plt.show()
  71. plt.plot(low_bits_4_svd_values[0], label='Noisy')
  72. plt.plot(low_bits_4_svd_values[1], label='Threshold')
  73. plt.plot(low_bits_4_svd_values[2], label='Reference')
  74. plt.ylabel('Low 4 bits SVD')
  75. plt.xlabel('Vector features')
  76. plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
  77. plt.ylim(0, 0.1)
  78. plt.show()
  79. plt.plot(low_bits_5_svd_values[0], label='Noisy')
  80. plt.plot(low_bits_5_svd_values[1], label='Threshold')
  81. plt.plot(low_bits_5_svd_values[2], label='Reference')
  82. plt.ylabel('Low 5 bits SVD')
  83. plt.xlabel('Vector features')
  84. plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
  85. plt.ylim(0, 0.1)
  86. plt.show()
  87. plt.plot(low_bits_6_svd_values[0], label='Noisy')
  88. plt.plot(low_bits_6_svd_values[1], label='Threshold')
  89. plt.plot(low_bits_6_svd_values[2], label='Reference')
  90. plt.ylabel('Low 6 bits SVD')
  91. plt.xlabel('Vector features')
  92. plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
  93. plt.ylim(0, 0.1)
  94. plt.show()
  95. plt.plot(low_bits_7_svd_values[0], label='Noisy')
  96. plt.plot(low_bits_7_svd_values[1], label='Threshold')
  97. plt.plot(low_bits_7_svd_values[2], label='Reference')
  98. plt.ylabel('Low 7 bits SVD')
  99. plt.xlabel('Vector features')
  100. plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
  101. plt.ylim(0, 0.1)
  102. plt.show()