Parcourir la source

Merge branch 'release/v0.0.5'

Jerome Buisine il y a 5 ans
Parent
commit
76f0309a83
3 fichiers modifiés avec 95 ajouts et 5 suppressions
  1. 10 0
      README.rst
  2. 83 4
      ipfml/metrics.py
  3. 2 1
      setup.py

+ 10 - 0
README.rst

@@ -29,6 +29,16 @@ This project contains modules.
     - get_SVD_U(image): *Transforms PIL Image into SVD and returns only 'U' part*
     - get_SVD_V(image): *Transforms PIL Image into SVD and returns only 'V' part*
 
+    - get_LAB(image): *Transforms PIL Image into LAB*
+    - get_LAB_L(image): *Transforms PIL Image into LAB and returns only 'L' part*
+    - get_LAB_A(image): *Transforms PIL Image into LAB and returns only 'A' part*
+    - get_LAB_B(image): *Transforms PIL Image into LAB and returns only 'B' part*
+
+    - get_XYZ(image): *Transforms PIL Image into XYZ*
+    - get_XYZ_X(image): *Transforms PIL Image into XYZ and returns only 'X' part*
+    - get_XYZ_Y(image): *Transforms PIL Image into XYZ and returns only 'Y' part*
+    - get_XYZ_Z(image): *Transforms PIL Image into XYZ and returns only 'Z' part*
+
 - **ts_model_helper** : *contains helpful function to save or display model information and performance of tensorflow model*
     - save(history, filename): *Function which saves data from neural network model*
     - show(history, filename): *Function which shows data from neural network model*

+ 83 - 4
ipfml/metrics.py

@@ -5,10 +5,11 @@ from scipy import misc
 
 import numpy as np
 from sklearn import preprocessing
+from skimage import io, color
 
 def get_SVD(image):
     """
-    @brief Transforms PIL Image into SVD
+    @brief Transforms Image into SVD
     @param image to convert
     @return U, s, V image decomposition
     """
@@ -16,7 +17,7 @@ def get_SVD(image):
 
 def get_SVD_s(image):
     """
-    @brief Transforms PIL Image into SVD and returns only 's' part
+    @brief Transforms Image into SVD and returns only 's' part
     @param image to convert
     @return s
     """
@@ -25,7 +26,7 @@ def get_SVD_s(image):
 
 def get_SVD_U(image):
     """
-    @brief Transforms PIL Image into SVD and returns only 'U' part
+    @brief Transforms Image into SVD and returns only 'U' part
     @param image to convert
     @return U
     """
@@ -34,9 +35,87 @@ def get_SVD_U(image):
 
 def get_SVD_V(image):
     """
-    @brief Transforms PIL Image into SVD and returns only 'V' part
+    @brief Transforms Image into SVD and returns only 'V' part
     @param image to convert
     @return V
     """
     U, s, V = svd(image, full_matrices=False)
     return V
+
+def get_LAB(image):
+    """
+    @brief Transforms PIL RGB Image into LAB 
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    return color.rgb2lab(rgb)
+
+def get_LAB_L(image):
+    """
+    @brief Transforms PIL RGB Image into LAB and returns L
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    lab = color.rgb2lab(rgb)
+    return lab[:, :, 0]
+
+def get_LAB_A(image):
+    """
+    @brief Transforms PIL RGB Image into LAB and returns A
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    lab = color.rgb2lab(rgb)
+    return lab[:, :, 1]
+
+def get_LAB_B(image):
+    """
+    @brief Transforms PIL RGB Image into LAB and returns B
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    lab = color.rgb2lab(rgb)
+    return lab[:, :, 2]
+
+def get_XYZ(image):
+    """
+    @brief Transforms PIL RGB Image into XYZ
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    return color.rgb2xyz(rgb)
+
+def get_XYZ_X(image):
+    """
+    @brief Transforms PIL RGB Image into XYZ and returns X
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    xyz = color.rgb2xyz(rgb)
+    return xyz[:, :, 0]
+
+def get_XYZ_Y(image):
+    """
+    @brief Transforms PIL RGB Image into XYZ and returns Y
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    xyz = color.rgb2xyz(rgb)
+    return xyz[:, :, 1]
+
+def get_XYZ_Z(image):
+    """
+    @brief Transforms PIL RGB Image into XYZ and returns Z
+    @param image to convert
+    @return Lab information
+    """
+    rgb = io.imread(image.filename)
+    xyz = color.rgb2xyz(rgb)
+    return xyz[:, :, 2]

+ 2 - 1
setup.py

@@ -5,7 +5,7 @@ def readme():
         return f.read()
 
 setup(name='IPFML',
-      version='0.0.4',
+      version='0.0.5',
       description='Image Processing For Machine Learning',
       long_description=readme(),
       classifiers=[
@@ -24,6 +24,7 @@ setup(name='IPFML',
           'numpy',
           'Pillow',
           'sklearn',
+          'skimage',
           'scipy'
       ],
       zip_safe=False)