Parcourir la source

Merge branch 'release/v0.1.5'

Jerome Buisine il y a 5 ans
Parent
commit
b50f0393af
5 fichiers modifiés avec 45 ajouts et 3 suppressions
  1. 1 0
      README.md
  2. 1 2
      README.rst
  3. 18 0
      ipfml/image_processing.py
  4. 24 0
      ipfml/metrics.py
  5. 1 1
      setup.py

+ 1 - 0
README.md

@@ -28,6 +28,7 @@ This project contains modules.
     - rgb_to_mscn(image): *Convert RGB Image into Mean Subtracted Contrast Normalized (MSCN) using only gray level*
     - rgb_to_grey_low_bits(image, bind=15): *Convert RGB Image into grey image using only 4 low bits values by default*
     - rgb_to_LAB_L_low_bits(image, bind=15): *Convert RGB Image into LAB L channel image using only 4 low bits values by default*
+    - rgb_to_LAB_L_bits(image, interval): *Convert RGB Image into LAB L channel image using specific interval of bits to keep (2, 5) such as example*
     - normalize_arr(arr): *Normalize array values*
     - normalize_arr_with_range(arr, min, max): *Normalize array values with specific min and max values*
     - normalize_2D_arr(arr): *Return 2D array normalize from its min and max values*

+ 1 - 2
README.rst

@@ -20,8 +20,6 @@ Modules
 This project contains modules.
 
 - **image_processing** : *Image processing module*
-    - fig2data(fig): *Convert a Matplotlib figure to a 3D numpy array with RGB channels and return it*
-    - fig2img(fig): *Convert a Matplotlib figure to a PIL Image in RGB format and return it*
     - get_LAB_L_SVD_U(image): *Returns U SVD from L of LAB Image information*
     - get_LAB_L_SVD_s(image): *Returns s (Singular values) SVD from L of LAB Image information*
     - get_LAB_L_SVD_V(image): *Returns V SVD from L of LAB Image information*
@@ -29,6 +27,7 @@ This project contains modules.
     - rgb_to_mscn(image): *Convert RGB Image into Mean Subtracted Contrast Normalized (MSCN) using only gray level*
     - rgb_to_grey_low_bits(image, bind=15): *Convert RGB Image into grey image using only 4 low bits values by default*
     - rgb_to_LAB_L_low_bits(image, bind=15): *Convert RGB Image into LAB L channel image using only 4 low bits values by default*
+    - rgb_to_LAB_L_bits(image, interval): *Convert RGB Image into LAB L channel image using specific interval of bits to keep (2, 5) such as example*
     - normalize_arr(arr): *Normalize array values*
     - normalize_arr_with_range(arr, min, max): *Normalize array values with specific min and max values*
     - normalize_2D_arr(arr): *Return 2D array normalize from its min and max values*

+ 18 - 0
ipfml/image_processing.py

@@ -296,6 +296,24 @@ def rgb_to_LAB_L_low_bits(image, bind=15):
 
     return metrics.get_low_bits_img(L_block, bind)
 
+def rgb_to_LAB_L_bits(image, interval):
+    """
+    @brief Returns only bits from LAB L canal specified into the interval
+    @param image to convert using this interval of bits value to keep
+    @param interval (begin, end) of bits values
+    @return Numpy array with reduced values
+
+    >>> from PIL import Image
+    >>> from ipfml import image_processing
+    >>> img = Image.open('./images/test_img.png')
+    >>> bits_Lab_l_img = image_processing.rgb_to_LAB_L_bits(img)
+    >>> bits_Lab_l_img.shape
+    (200, 200)
+    """
+
+    L_block = np.asarray(metrics.get_LAB_L(image), 'uint8')
+
+    return metrics.get_bits_img(L_block, interval)
 
 # TODO : Check this method too...
 def get_random_active_block(blocks, threshold = 0.1):

+ 24 - 0
ipfml/metrics.py

@@ -275,6 +275,30 @@ def get_low_bits_img(image, bind=15):
 
     return img_arr & bind
 
+def get_bits_img(image, interval):
+    """
+    @brief Returns only bits specified into the interval
+    @param image to convert using this interval of bits value to keep
+    @param interval (begin, end) of bits values
+    @return Numpy array with reduced values
+
+    Usage :
+
+    >>> from PIL import Image
+    >>> from ipfml import metrics
+    >>> img = Image.open('./images/test_img.png')
+    >>> bits_img = metrics.get_bits_img(img, (2, 5))
+    >>> bits_img.shape
+    (200, 200, 3)
+    """
+
+    img_arr = np.array(image)
+    begin, end = interval
+
+    bits_values = sum([pow(2, i - 1) for i in range(begin, end + 1)])
+
+    return img_arr & bits_values
+
 
 def gray_to_mscn(image):
     """

+ 1 - 1
setup.py

@@ -21,7 +21,7 @@ class BuildTestCommand(setuptools.command.build_py.build_py):
     setuptools.command.build_py.build_py.run(self)
 
 setup(name='IPFML',
-      version='0.1.4',
+      version='0.1.5',
       description='Image Processing For Machine Learning',
       long_description=readme(),
       classifiers=[