svd_metric.py 699 B

123456789101112131415161718192021222324252627282930
  1. # module file which contains all image metrics used in project
  2. from numpy.linalg import svd
  3. from PIL import Image
  4. from scipy import misc
  5. '''
  6. Method which extracts SVD features from image and returns 's' vector
  7. @return 's' vector
  8. '''
  9. def get_s_model_data(image):
  10. U, s, V = svd(image, full_matrices=False)
  11. size = len(s)
  12. result = s.reshape([size, 1, 1]) # one shape per canal
  13. return result
  14. def get(image):
  15. return svd(image, full_matrices=False)
  16. def get_s(image):
  17. U, s, V = svd(image, full_matrices=False)
  18. return s
  19. def get_U(image):
  20. U, s, V = svd(image, full_matrices=False)
  21. return U
  22. def get_V(image):
  23. U, s, V = svd(image, full_matrices=False)
  24. return V