Browse Source

Update of salt_pepper noise filter

Jérôme BUISINE 1 year ago
parent
commit
503c253fdb
35 changed files with 393 additions and 66 deletions
  1. BIN
      docs/build/doctrees/environment.pickle
  2. BIN
      docs/build/doctrees/ipfml/ipfml.metrics.doctree
  3. BIN
      docs/build/doctrees/ipfml/ipfml.utils.doctree
  4. 1 1
      docs/build/html/.buildinfo
  5. 2 2
      docs/build/html/_modules/index.html
  6. 2 2
      docs/build/html/_modules/ipfml/exceptions.html
  7. 19 3
      docs/build/html/_modules/ipfml/filters/noise.html
  8. 2 2
      docs/build/html/_modules/ipfml/iqa/fr.html
  9. 5 4
      docs/build/html/_modules/ipfml/metrics.html
  10. 2 2
      docs/build/html/_modules/ipfml/processing.html
  11. 95 2
      docs/build/html/_modules/ipfml/utils.html
  12. 3 0
      docs/build/html/_sources/ipfml/ipfml.utils.rst.txt
  13. 1 1
      docs/build/html/_static/documentation_options.js
  14. 2 2
      docs/build/html/contributing.html
  15. 2 2
      docs/build/html/description.html
  16. 2 2
      docs/build/html/examples.html
  17. 10 4
      docs/build/html/genindex.html
  18. 2 2
      docs/build/html/index.html
  19. 2 2
      docs/build/html/ipfml.html
  20. 2 2
      docs/build/html/ipfml/ipfml.exceptions.html
  21. 2 2
      docs/build/html/ipfml/ipfml.filters.noise.html
  22. 2 2
      docs/build/html/ipfml/ipfml.iqa.fr.html
  23. 5 4
      docs/build/html/ipfml/ipfml.metrics.html
  24. 2 2
      docs/build/html/ipfml/ipfml.processing.html
  25. 103 9
      docs/build/html/ipfml/ipfml.utils.html
  26. BIN
      docs/build/html/objects.inv
  27. 2 2
      docs/build/html/py-modindex.html
  28. 2 2
      docs/build/html/search.html
  29. 1 1
      docs/build/html/searchindex.js
  30. 3 3
      docs/source/conf.py
  31. 3 0
      docs/source/ipfml/ipfml.utils.rst
  32. 17 1
      ipfml/filters/noise.py
  33. 3 2
      ipfml/metrics.py
  34. 93 0
      ipfml/utils.py
  35. 1 1
      setup.py

BIN
docs/build/doctrees/environment.pickle


BIN
docs/build/doctrees/ipfml/ipfml.metrics.doctree


BIN
docs/build/doctrees/ipfml/ipfml.utils.doctree


+ 1 - 1
docs/build/html/.buildinfo

@@ -1,4 +1,4 @@
 # Sphinx build info version 1
 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
-config: b62be055d9befed35a84e386cd584bb4
+config: 6e8868967918653db8d0aa1efdf78b9d
 tags: 645f666f9bcd5a90fca523b33c5a78b7

+ 2 - 2
docs/build/html/_modules/index.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Overview: module code &mdash; IPFML v0.3.5 documentation</title>
+  <title>Overview: module code &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/_modules/ipfml/exceptions.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.exceptions &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.exceptions &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 19 - 3
docs/build/html/_modules/ipfml/filters/noise.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.filters.noise &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.filters.noise &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           
@@ -500,6 +500,19 @@
 
         <span class="k">return</span> <span class="n">elements</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">w</span><span class="p">)</span>
 
+    <span class="n">image_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">image</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">image_array</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
+        <span class="n">height</span><span class="p">,</span> <span class="n">width</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">image_array</span><span class="o">.</span><span class="n">shape</span>
+    <span class="k">else</span><span class="p">:</span>
+        <span class="n">height</span><span class="p">,</span> <span class="n">width</span> <span class="o">=</span> <span class="n">image_array</span><span class="o">.</span><span class="n">shape</span>
+
+    <span class="c1"># need same random variable for each pixel value if identical</span>
+    <span class="k">if</span> <span class="n">identical</span><span class="p">:</span>
+        <span class="n">gen</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">height</span> <span class="o">*</span> <span class="n">width</span><span class="p">)</span>
+        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">):</span>
+            <span class="n">gen</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">gen</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">gen</span><span class="p">)</span>
+        <span class="n">gen</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">gen</span><span class="p">)</span>
+
     <span class="c1"># here noise variable is boolean to update or not pixel value</span>
     <span class="k">def</span> <span class="nf">_updator</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">noise</span><span class="p">):</span>
 
@@ -508,7 +521,10 @@
             <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">_updator</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">noise</span><span class="p">)))</span>
 
         <span class="c1"># probabilty to increase or decrease pixel value</span>
-        <span class="n">rand</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">identical</span><span class="p">:</span>
+            <span class="n">rand</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="n">gen</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">rand</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
 
         <span class="k">if</span> <span class="n">noise</span><span class="p">:</span>
             <span class="k">if</span> <span class="n">rand</span> <span class="o">&gt;</span> <span class="mf">0.5</span><span class="p">:</span>

+ 2 - 2
docs/build/html/_modules/ipfml/iqa/fr.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.iqa.fr &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.iqa.fr &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 5 - 4
docs/build/html/_modules/ipfml/metrics.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.metrics &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.metrics &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           
@@ -533,9 +533,10 @@
 <span class="sd">    Usage:</span>
 
 <span class="sd">    &gt;&gt;&gt; from PIL import Image</span>
-<span class="sd">    &gt;&gt;&gt; from ipfml import processing</span>
+<span class="sd">    &gt;&gt;&gt; from ipfml import metrics</span>
 <span class="sd">    &gt;&gt;&gt; img = Image.open(&#39;./images/test_img.png&#39;)</span>
-<span class="sd">    &gt;&gt;&gt; img_mscn = processing.rgb_to_mscn(img)</span>
+<span class="sd">    &gt;&gt;&gt; img = metrics.get_LAB_L(img)</span>
+<span class="sd">    &gt;&gt;&gt; img_mscn = metrics.gray_to_mscn(img)</span>
 <span class="sd">    &gt;&gt;&gt; img_mscn.shape</span>
 <span class="sd">    (200, 200)</span>
 <span class="sd">    &quot;&quot;&quot;</span>

+ 2 - 2
docs/build/html/_modules/ipfml/processing.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.processing &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.processing &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

File diff suppressed because it is too large
+ 95 - 2
docs/build/html/_modules/ipfml/utils.html


+ 3 - 0
docs/build/html/_sources/ipfml/ipfml.utils.rst.txt

@@ -9,6 +9,9 @@ ipfml.utils
 
    .. autosummary::
    
+      get_entropy
+      get_entropy_contribution_of_i
+      get_entropy_without_i
       get_indices_of_highest_values
       get_indices_of_lowest_values
       integral_area_simps

+ 1 - 1
docs/build/html/_static/documentation_options.js

@@ -1,6 +1,6 @@
 var DOCUMENTATION_OPTIONS = {
     URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
-    VERSION: 'v0.3.5',
+    VERSION: 'v0.3.6',
     LANGUAGE: 'None',
     COLLAPSE_INDEX: false,
     FILE_SUFFIX: '.html',

+ 2 - 2
docs/build/html/contributing.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Contributing &mdash; IPFML v0.3.5 documentation</title>
+  <title>Contributing &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -57,7 +57,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/description.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Description &mdash; IPFML v0.3.5 documentation</title>
+  <title>Description &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/examples.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Examples &mdash; IPFML v0.3.5 documentation</title>
+  <title>Examples &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 10 - 4
docs/build/html/genindex.html

@@ -9,7 +9,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Index &mdash; IPFML v0.3.5 documentation</title>
+  <title>Index &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -57,7 +57,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           
@@ -202,6 +202,12 @@
       <li><a href="ipfml/ipfml.filters.noise.html#ipfml.filters.noise.gaussian_noise">gaussian_noise() (in module ipfml.filters.noise)</a>
 </li>
       <li><a href="ipfml/ipfml.metrics.html#ipfml.metrics.get_bits_img">get_bits_img() (in module ipfml.metrics)</a>
+</li>
+      <li><a href="ipfml/ipfml.utils.html#ipfml.utils.get_entropy">get_entropy() (in module ipfml.utils)</a>
+</li>
+      <li><a href="ipfml/ipfml.utils.html#ipfml.utils.get_entropy_contribution_of_i">get_entropy_contribution_of_i() (in module ipfml.utils)</a>
+</li>
+      <li><a href="ipfml/ipfml.utils.html#ipfml.utils.get_entropy_without_i">get_entropy_without_i() (in module ipfml.utils)</a>
 </li>
       <li><a href="ipfml/ipfml.utils.html#ipfml.utils.get_indices_of_highest_values">get_indices_of_highest_values() (in module ipfml.utils)</a>
 </li>
@@ -218,11 +224,11 @@
       <li><a href="ipfml/ipfml.processing.html#ipfml.processing.get_LAB_L_SVD">get_LAB_L_SVD() (in module ipfml.processing)</a>
 </li>
       <li><a href="ipfml/ipfml.processing.html#ipfml.processing.get_LAB_L_SVD_s">get_LAB_L_SVD_s() (in module ipfml.processing)</a>
-</li>
-      <li><a href="ipfml/ipfml.processing.html#ipfml.processing.get_LAB_L_SVD_U">get_LAB_L_SVD_U() (in module ipfml.processing)</a>
 </li>
   </ul></td>
   <td style="width: 33%; vertical-align: top;"><ul>
+      <li><a href="ipfml/ipfml.processing.html#ipfml.processing.get_LAB_L_SVD_U">get_LAB_L_SVD_U() (in module ipfml.processing)</a>
+</li>
       <li><a href="ipfml/ipfml.processing.html#ipfml.processing.get_LAB_L_SVD_V">get_LAB_L_SVD_V() (in module ipfml.processing)</a>
 </li>
       <li><a href="ipfml/ipfml.metrics.html#ipfml.metrics.get_low_bits_img">get_low_bits_img() (in module ipfml.metrics)</a>

+ 2 - 2
docs/build/html/index.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Image Processing For Machine Learning &mdash; IPFML v0.3.5 documentation</title>
+  <title>Image Processing For Machine Learning &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -57,7 +57,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/ipfml.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Documentation &mdash; IPFML v0.3.5 documentation</title>
+  <title>Documentation &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/ipfml/ipfml.exceptions.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.exceptions &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.exceptions &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/ipfml/ipfml.filters.noise.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.filters.noise &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.filters.noise &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/ipfml/ipfml.iqa.fr.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.iqa.fr &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.iqa.fr &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 5 - 4
docs/build/html/ipfml/ipfml.metrics.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.metrics &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.metrics &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           
@@ -608,9 +608,10 @@
 </table>
 <p>Usage:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
-<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">processing</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">metrics</span>
 <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;./images/test_img.png&#39;</span><span class="p">)</span>
-<span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rgb_to_mscn</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_LAB_L</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">gray_to_mscn</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
 <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span><span class="o">.</span><span class="n">shape</span>
 <span class="go">(200, 200)</span>
 </pre></div>

+ 2 - 2
docs/build/html/ipfml/ipfml.processing.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.processing &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.processing &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 103 - 9
docs/build/html/ipfml/ipfml.utils.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>ipfml.utils &mdash; IPFML v0.3.5 documentation</title>
+  <title>ipfml.utils &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           
@@ -174,29 +174,123 @@
 <col width="90%" />
 </colgroup>
 <tbody valign="top">
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_highest_values" title="ipfml.utils.get_indices_of_highest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_highest_values</span></code></a>(arr,&nbsp;n)</td>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_entropy" title="ipfml.utils.get_entropy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_entropy</span></code></a>(arr)</td>
+<td>Returns the computed entropy from arr</td>
+</tr>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.get_entropy_contribution_of_i" title="ipfml.utils.get_entropy_contribution_of_i"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_entropy_contribution_of_i</span></code></a>(arr,&nbsp;i)</td>
+<td>Returns the entropy contribution i column</td>
+</tr>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_entropy_without_i" title="ipfml.utils.get_entropy_without_i"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_entropy_without_i</span></code></a>(arr,&nbsp;i)</td>
+<td>Returns the computed entropy from arr without contribution of i</td>
+</tr>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_highest_values" title="ipfml.utils.get_indices_of_highest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_highest_values</span></code></a>(arr,&nbsp;n)</td>
 <td>Returns indices of n highest values from list or 1D numpy array</td>
 </tr>
-<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_lowest_values" title="ipfml.utils.get_indices_of_lowest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_lowest_values</span></code></a>(arr,&nbsp;n)</td>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_lowest_values" title="ipfml.utils.get_indices_of_lowest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_lowest_values</span></code></a>(arr,&nbsp;n)</td>
 <td>Returns indices of n highest values from list or 1D numpy array</td>
 </tr>
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.integral_area_simps" title="ipfml.utils.integral_area_simps"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_simps</span></code></a>(y_values,&nbsp;dx)</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.integral_area_simps" title="ipfml.utils.integral_area_simps"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_simps</span></code></a>(y_values,&nbsp;dx)</td>
 <td>Returns area under curves from provided data points using Simpsons rule</td>
 </tr>
-<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.integral_area_trapz" title="ipfml.utils.integral_area_trapz"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_trapz</span></code></a>(y_values,&nbsp;dx)</td>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.integral_area_trapz" title="ipfml.utils.integral_area_trapz"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_trapz</span></code></a>(y_values,&nbsp;dx)</td>
 <td>Returns area under curves from provided data points using Trapezium rule</td>
 </tr>
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.normalize_2D_arr" title="ipfml.utils.normalize_2D_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_2D_arr</span></code></a>(arr)</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.normalize_2D_arr" title="ipfml.utils.normalize_2D_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_2D_arr</span></code></a>(arr)</td>
 <td>Return array normalize from its min and max values</td>
 </tr>
-<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.normalize_arr" title="ipfml.utils.normalize_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr</span></code></a>(arr)</td>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.normalize_arr" title="ipfml.utils.normalize_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr</span></code></a>(arr)</td>
 <td>Normalize data of 1D array shape</td>
 </tr>
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.normalize_arr_with_range" title="ipfml.utils.normalize_arr_with_range"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr_with_range</span></code></a>(arr,&nbsp;min,&nbsp;max)</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.normalize_arr_with_range" title="ipfml.utils.normalize_arr_with_range"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr_with_range</span></code></a>(arr,&nbsp;min,&nbsp;max)</td>
 <td>Normalize data of 1D array shape</td>
 </tr>
 </tbody>
 </table>
+<dl class="function">
+<dt id="ipfml.utils.get_entropy">
+<code class="descclassname">ipfml.utils.</code><code class="descname">get_entropy</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_entropy" title="Permalink to this definition">¶</a></dt>
+<dd><p>Returns the computed entropy from arr</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – numpy array</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">entropy score computed</td>
+</tr>
+</tbody>
+</table>
+<p>Example:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">entropy</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_entropy</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
+<span class="go">0</span>
+</pre></div>
+</div>
+</dd></dl>
+
+<dl class="function">
+<dt id="ipfml.utils.get_entropy_contribution_of_i">
+<code class="descclassname">ipfml.utils.</code><code class="descname">get_entropy_contribution_of_i</code><span class="sig-paren">(</span><em>arr</em>, <em>i</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_entropy_contribution_of_i"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_entropy_contribution_of_i" title="Permalink to this definition">¶</a></dt>
+<dd><p>Returns the entropy contribution i column</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>arr</strong> – numpy array</li>
+<li><strong>i</strong> – column index</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">entropy contribution score computed</p>
+</td>
+</tr>
+</tbody>
+</table>
+<p>Example:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">entropy</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_entropy_contribution_of_i</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
+<span class="go">0</span>
+</pre></div>
+</div>
+</dd></dl>
+
+<dl class="function">
+<dt id="ipfml.utils.get_entropy_without_i">
+<code class="descclassname">ipfml.utils.</code><code class="descname">get_entropy_without_i</code><span class="sig-paren">(</span><em>arr</em>, <em>i</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_entropy_without_i"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_entropy_without_i" title="Permalink to this definition">¶</a></dt>
+<dd><p>Returns the computed entropy from arr without contribution of i</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>arr</strong> – numpy array</li>
+<li><strong>i</strong> – column index</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">entropy score computed</p>
+</td>
+</tr>
+</tbody>
+</table>
+<p>Example:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">entropy</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_entropy_without_i</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
+<span class="go">0</span>
+</pre></div>
+</div>
+</dd></dl>
+
 <dl class="function">
 <dt id="ipfml.utils.get_indices_of_highest_values">
 <code class="descclassname">ipfml.utils.</code><code class="descname">get_indices_of_highest_values</code><span class="sig-paren">(</span><em>arr</em>, <em>n</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_indices_of_highest_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_indices_of_highest_values" title="Permalink to this definition">¶</a></dt>

BIN
docs/build/html/objects.inv


+ 2 - 2
docs/build/html/py-modindex.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Python Module Index &mdash; IPFML v0.3.5 documentation</title>
+  <title>Python Module Index &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -59,7 +59,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

+ 2 - 2
docs/build/html/search.html

@@ -8,7 +8,7 @@
   
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   
-  <title>Search &mdash; IPFML v0.3.5 documentation</title>
+  <title>Search &mdash; IPFML v0.3.6 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.5
+                0.3.6
               </div>
             
           

File diff suppressed because it is too large
+ 1 - 1
docs/build/html/searchindex.js


+ 3 - 3
docs/source/conf.py

@@ -24,9 +24,9 @@ copyright = '2019, Jérôme BUISINE'
 author = 'Jérôme BUISINE'
 
 # The short X.Y version
-version = '0.3.5'
-# The full versiabson, including alpha/beta/rc tags
-release = 'v0.3.5'
+version = '0.3.6'
+# The full version, including alpha/beta/rc tags
+release = 'v0.3.6'
 
 
 # -- General configuration ---------------------------------------------------

+ 3 - 0
docs/source/ipfml/ipfml.utils.rst

@@ -9,6 +9,9 @@ ipfml.utils
 
    .. autosummary::
    
+      get_entropy
+      get_entropy_contribution_of_i
+      get_entropy_without_i
       get_indices_of_highest_values
       get_indices_of_lowest_values
       integral_area_simps

+ 17 - 1
ipfml/filters/noise.py

@@ -349,6 +349,19 @@ def salt_pepper_noise(image, n, identical=False, p=0.1, k=0.5):
 
         return elements.reshape(h, w)
 
+    image_array = np.array(image)
+    if image_array.ndim == 3:
+        height, width, _ = image_array.shape
+    else:
+        height, width = image_array.shape
+
+    # need same random variable for each pixel value if identical
+    if identical:
+        gen = np.random.uniform(0, 1, height * width)
+        for i in range(2):
+            gen = np.insert(gen, 0, gen)
+        gen = iter(gen)
+
     # here noise variable is boolean to update or not pixel value
     def _updator(x, noise):
 
@@ -357,7 +370,10 @@ def salt_pepper_noise(image, n, identical=False, p=0.1, k=0.5):
             return np.array(list(map(_updator, x, noise)))
 
         # probabilty to increase or decrease pixel value
-        rand = random.uniform(0, 1)
+        if identical:
+            rand = next(gen)
+        else:
+            rand = random.uniform(0, 1)
 
         if noise:
             if rand > 0.5:

+ 3 - 2
ipfml/metrics.py

@@ -382,9 +382,10 @@ def gray_to_mscn(image):
     Usage:
 
     >>> from PIL import Image
-    >>> from ipfml import processing
+    >>> from ipfml import metrics
     >>> img = Image.open('./images/test_img.png')
-    >>> img_mscn = processing.rgb_to_mscn(img)
+    >>> img = metrics.get_LAB_L(img)
+    >>> img_mscn = metrics.gray_to_mscn(img)
     >>> img_mscn.shape
     (200, 200)
     """

+ 93 - 0
ipfml/utils.py

@@ -3,6 +3,7 @@ Utils functions of ipfml package (array normalization)
 """
 
 import numpy as np
+import math
 
 from scipy.integrate import simps
 
@@ -187,3 +188,95 @@ def get_indices_of_lowest_values(arr, n):
     array([0, 1])
     """
     return np.array(arr).argsort()[::-1][-n:][::-1]
+
+
+def get_entropy(arr):
+    """Returns the computed entropy from arr
+
+    Args:
+        arr: numpy array
+
+    Returns:
+        entropy score computed
+
+    Example:
+
+    >>> from ipfml import utils
+    >>> import numpy as np
+    >>> arr = np.arange(10)
+    >>> entropy = utils.get_entropy(arr)
+    >>> int(entropy)
+    0
+    """
+
+    arr = np.array(arr)
+    eigen_values = []
+    sum_eigen_values = (arr * arr).sum()
+
+    for val in arr:
+        eigen_values.append(val * val)
+
+    v = []
+
+    for val in eigen_values:
+        v.append(val / sum_eigen_values)
+
+    entropy = 0
+
+    for val in v:
+        if val > 0:
+            entropy += val * math.log(val)
+
+    entropy *= -1
+
+    entropy /= math.log(len(v))
+
+    return entropy
+
+
+def get_entropy_without_i(arr, i):
+    """Returns the computed entropy from arr without contribution of i
+
+    Args:
+        arr: numpy array
+        i: column index
+
+    Returns:
+        entropy score computed
+
+    Example:
+
+    >>> from ipfml import utils
+    >>> import numpy as np
+    >>> arr = np.arange(10)
+    >>> entropy = utils.get_entropy_without_i(arr, 3)
+    >>> int(entropy)
+    0
+    """
+
+    arr = np.array([v for index, v in enumerate(arr) if index != i])
+
+    return get_entropy(arr)
+
+
+def get_entropy_contribution_of_i(arr, i):
+    """Returns the entropy contribution i column
+
+    Args:
+        arr: numpy array
+        i: column index
+
+    Returns:
+        entropy contribution score computed
+
+    Example:
+
+    >>> from ipfml import utils
+    >>> import numpy as np
+    >>> arr = np.arange(10)
+    >>> entropy = utils.get_entropy_contribution_of_i(arr, 3)
+    >>> int(entropy)
+    0
+    """
+
+    return get_entropy(arr) - get_entropy_without_i(arr, i)

+ 1 - 1
setup.py

@@ -31,7 +31,7 @@ class BuildTestCommand(setuptools.command.build_py.build_py):
 
 setup(
     name='ipfml',
-    version='0.3.5',
+    version='0.3.6',
     description='Image Processing For Machine Learning',
     long_description=readme(),
     classifiers=[