Parcourir la source

Add of low bits metrics

Jerome Buisine il y a 5 ans
Parent
commit
4863e7902b
3 fichiers modifiés avec 26 ajouts et 2 suppressions
  1. 13 1
      ipfml/image_processing.py
  2. 12 0
      ipfml/metrics.py
  3. 1 1
      setup.py

+ 13 - 1
ipfml/image_processing.py

@@ -253,7 +253,7 @@ def rgb_to_mscn(image):
 
     # convert rgb image to gray
     im = np.array(color.rgb2gray(img_arr)*255, 'uint8')
-
+    
     s = 7/6
     blurred = cv2.GaussianBlur(im, (7, 7), s) # apply gaussian blur to the image
     blurred_sq = blurred * blurred 
@@ -264,6 +264,18 @@ def rgb_to_mscn(image):
 
     return structdis
 
+# TODO : add test to this method...
+def rgb_to_grey_low_bits(image, bind=15):
+    """
+    @brief Convert RGB Image into grey image using only 4 low bits values
+    @param 3D RGB image numpy array or PIL RGB image 
+    """
+
+    img_arr = np.array(image)
+    grey_block = np.array(color.rgb2gray(img_arr)*255, 'uint8')
+    
+    return metrics.get_low_bits_img(grey_block, bind)
+
 # TODO : Check this method too...
 def get_random_active_block(blocks, threshold = 0.1):
     """

+ 12 - 0
ipfml/metrics.py

@@ -267,3 +267,15 @@ def get_XYZ_Z(image):
     rgb = io.imread(file_path)
     xyz = color.rgb2xyz(rgb)
     return xyz[:, :, 2]
+
+def get_low_bits_img(image, bind=15):
+    """
+    @brief Returns Image or Numpy array with data information reduced using only low bits
+    @param image to convert
+    @bind optional : bits to keep using & Bitwise operator
+    @return Numpy array with reduced values
+    """
+    
+    img_arr = np.array(image)
+
+    return img_arr & bind

+ 1 - 1
setup.py

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