Browse Source

Add of reconstruction methods for processing

Jérôme BUISINE 1 year ago
parent
commit
18f746547f
33 changed files with 386 additions and 58 deletions
  1. 3 0
      .gitignore
  2. BIN
      docs/build/doctrees/environment.pickle
  3. BIN
      docs/build/doctrees/ipfml/ipfml.processing.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. 2 2
      docs/build/html/_modules/ipfml/filters/noise.html
  8. 2 2
      docs/build/html/_modules/ipfml/iqa/fr.html
  9. 2 2
      docs/build/html/_modules/ipfml/metrics.html
  10. 107 3
      docs/build/html/_modules/ipfml/processing.html
  11. 2 2
      docs/build/html/_modules/ipfml/utils.html
  12. 3 0
      docs/build/html/_sources/ipfml/ipfml.processing.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. 12 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. 2 2
      docs/build/html/ipfml/ipfml.metrics.html
  24. 111 8
      docs/build/html/ipfml/ipfml.processing.html
  25. 2 2
      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. 2 2
      docs/source/conf.py
  31. 3 0
      docs/source/ipfml/ipfml.processing.rst
  32. 105 1
      ipfml/processing.py
  33. 1 1
      setup.py

+ 3 - 0
.gitignore

@@ -58,3 +58,6 @@ target/
 
 # Docs
 !docs/build
+
+# IDE
+.vscode

BIN
docs/build/doctrees/environment.pickle


BIN
docs/build/doctrees/ipfml/ipfml.processing.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: 3851cca056eb090dcaec58eecc5894f7
+config: 29e6f78aa0a4cae0290113e20494277d
 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.9 documentation</title>
+  <title>Overview: module code &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>ipfml.exceptions &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

+ 2 - 2
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.9 documentation</title>
+  <title>ipfml.filters.noise &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

+ 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.9 documentation</title>
+  <title>ipfml.iqa.fr &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

+ 2 - 2
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.9 documentation</title>
+  <title>ipfml.metrics &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

File diff suppressed because it is too large
+ 107 - 3
docs/build/html/_modules/ipfml/processing.html


+ 2 - 2
docs/build/html/_modules/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.9 documentation</title>
+  <title>ipfml.utils &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

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

@@ -10,17 +10,20 @@ ipfml.processing
    .. autosummary::
    
       divide_in_blocks
+      fast_ica_reconstruction
       fusion_images
       get_LAB_L_SVD
       get_LAB_L_SVD_U
       get_LAB_L_SVD_V
       get_LAB_L_SVD_s
       get_mscn_coefficients
+      ipca_reconstruction
       rgb_to_LAB_L_bits
       rgb_to_LAB_L_low_bits
       rgb_to_grey_low_bits
       rgb_to_mscn
       rotate_image
+      svd_reconstruction
    
    
 

+ 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.9',
+    VERSION: 'v0.4.0',
     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.9 documentation</title>
+  <title>Contributing &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -57,7 +57,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>Description &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>Examples &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

+ 12 - 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.9 documentation</title>
+  <title>Index &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -57,7 +57,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           
@@ -190,6 +190,10 @@
 
 <h2 id="F">F</h2>
 <table style="width: 100%" class="indextable genindextable"><tr>
+  <td style="width: 33%; vertical-align: top;"><ul>
+      <li><a href="ipfml/ipfml.processing.html#ipfml.processing.fast_ica_reconstruction">fast_ica_reconstruction() (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.fusion_images">fusion_images() (in module ipfml.processing)</a>
 </li>
@@ -263,12 +267,14 @@
 </li>
       <li><a href="ipfml/ipfml.utils.html#ipfml.utils.integral_area_trapz">integral_area_trapz() (in module ipfml.utils)</a>
 </li>
-      <li><a href="ipfml/ipfml.exceptions.html#module-ipfml.exceptions">ipfml.exceptions (module)</a>
+      <li><a href="ipfml/ipfml.processing.html#ipfml.processing.ipca_reconstruction">ipca_reconstruction() (in module ipfml.processing)</a>
 </li>
-      <li><a href="ipfml/ipfml.filters.noise.html#module-ipfml.filters.noise">ipfml.filters.noise (module)</a>
+      <li><a href="ipfml/ipfml.exceptions.html#module-ipfml.exceptions">ipfml.exceptions (module)</a>
 </li>
   </ul></td>
   <td style="width: 33%; vertical-align: top;"><ul>
+      <li><a href="ipfml/ipfml.filters.noise.html#module-ipfml.filters.noise">ipfml.filters.noise (module)</a>
+</li>
       <li><a href="ipfml/ipfml.iqa.fr.html#module-ipfml.iqa.fr">ipfml.iqa.fr (module)</a>
 </li>
       <li><a href="ipfml/ipfml.metrics.html#module-ipfml.metrics">ipfml.metrics (module)</a>
@@ -362,6 +368,8 @@
   </ul></td>
   <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="ipfml/ipfml.iqa.fr.html#ipfml.iqa.fr.ssim">ssim() (in module ipfml.iqa.fr)</a>
+</li>
+      <li><a href="ipfml/ipfml.processing.html#ipfml.processing.svd_reconstruction">svd_reconstruction() (in module ipfml.processing)</a>
 </li>
   </ul></td>
 </tr></table>

+ 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.9 documentation</title>
+  <title>Image Processing For Machine Learning &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -57,7 +57,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>Documentation &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>ipfml.exceptions &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>ipfml.filters.noise &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>ipfml.iqa.fr &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

+ 2 - 2
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.9 documentation</title>
+  <title>ipfml.metrics &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

+ 111 - 8
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.9 documentation</title>
+  <title>ipfml.processing &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           
@@ -177,24 +177,30 @@
 <tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.divide_in_blocks" title="ipfml.processing.divide_in_blocks"><code class="xref py py-obj docutils literal notranslate"><span class="pre">divide_in_blocks</span></code></a>(image,&nbsp;block_size[,&nbsp;pil])</td>
 <td>Divide image into equal size blocks</td>
 </tr>
-<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.fusion_images" title="ipfml.processing.fusion_images"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fusion_images</span></code></a>(images[,&nbsp;pil])</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.fast_ica_reconstruction" title="ipfml.processing.fast_ica_reconstruction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fast_ica_reconstruction</span></code></a>(image,&nbsp;components)</td>
+<td>Reconstruct an image from SVD compression using specific number of components to use</td>
+</tr>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.fusion_images" title="ipfml.processing.fusion_images"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fusion_images</span></code></a>(images[,&nbsp;pil])</td>
 <td>Fusion array of images into single image</td>
 </tr>
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD" title="ipfml.processing.get_LAB_L_SVD"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD</span></code></a>(image)</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD" title="ipfml.processing.get_LAB_L_SVD"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD</span></code></a>(image)</td>
 <td>Returns Singular values from LAB L Image information</td>
 </tr>
-<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD_U" title="ipfml.processing.get_LAB_L_SVD_U"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD_U</span></code></a>(image)</td>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD_U" title="ipfml.processing.get_LAB_L_SVD_U"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD_U</span></code></a>(image)</td>
 <td>Returns U SVD from L of LAB Image information</td>
 </tr>
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD_V" title="ipfml.processing.get_LAB_L_SVD_V"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD_V</span></code></a>(image)</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD_V" title="ipfml.processing.get_LAB_L_SVD_V"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD_V</span></code></a>(image)</td>
 <td>Returns V SVD from L of LAB Image information</td>
 </tr>
-<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD_s" title="ipfml.processing.get_LAB_L_SVD_s"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD_s</span></code></a>(image)</td>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.get_LAB_L_SVD_s" title="ipfml.processing.get_LAB_L_SVD_s"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_LAB_L_SVD_s</span></code></a>(image)</td>
 <td>Returns s (Singular values) SVD from L of LAB Image information</td>
 </tr>
-<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.get_mscn_coefficients" title="ipfml.processing.get_mscn_coefficients"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_mscn_coefficients</span></code></a>(image)</td>
+<tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.get_mscn_coefficients" title="ipfml.processing.get_mscn_coefficients"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_mscn_coefficients</span></code></a>(image)</td>
 <td>Compute the Mean Substracted Constrast Normalized coefficients of an image</td>
 </tr>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.ipca_reconstruction" title="ipfml.processing.ipca_reconstruction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ipca_reconstruction</span></code></a>(image,&nbsp;components[,&nbsp;…])</td>
+<td>Reconstruct an image from SVD compression using specific number of components to use and batch size</td>
+</tr>
 <tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.rgb_to_LAB_L_bits" title="ipfml.processing.rgb_to_LAB_L_bits"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rgb_to_LAB_L_bits</span></code></a>(image,&nbsp;interval)</td>
 <td>Returns only bits from LAB L canal specified into the interval</td>
 </tr>
@@ -210,6 +216,9 @@
 <tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.rotate_image" title="ipfml.processing.rotate_image"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rotate_image</span></code></a>(image[,&nbsp;angle,&nbsp;pil])</td>
 <td>Rotate image using specific angle</td>
 </tr>
+<tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.svd_reconstruction" title="ipfml.processing.svd_reconstruction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">svd_reconstruction</span></code></a>(image,&nbsp;interval)</td>
+<td>Reconstruct an image from SVD compression using specific interval of Singular Values</td>
+</tr>
 </tbody>
 </table>
 <dl class="function">
@@ -259,6 +268,37 @@
 </div>
 </dd></dl>
 
+<dl class="function">
+<dt id="ipfml.processing.fast_ica_reconstruction">
+<code class="descclassname">ipfml.processing.</code><code class="descname">fast_ica_reconstruction</code><span class="sig-paren">(</span><em>image</em>, <em>components</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#fast_ica_reconstruction"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.fast_ica_reconstruction" title="Permalink to this definition">¶</a></dt>
+<dd><p>Reconstruct an image from SVD compression using specific number of components to use</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>image</strong> – PIL Image, Numpy array or path of 3D image</li>
+<li><strong>components</strong> – Number of components used for reconstruction</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Reconstructed image</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">PIL</span> <span class="k">import</span> <span class="n">Image</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="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="n">image_values</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">reconstructed_image</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">fast_ica_reconstruction</span><span class="p">(</span><span class="n">image_values</span><span class="p">,</span> <span class="mi">25</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">reconstructed_image</span><span class="o">.</span><span class="n">shape</span>
+<span class="go">(200, 200)</span>
+</pre></div>
+</div>
+</dd></dl>
+
 <dl class="function">
 <dt id="ipfml.processing.fusion_images">
 <code class="descclassname">ipfml.processing.</code><code class="descname">fusion_images</code><span class="sig-paren">(</span><em>images</em>, <em>pil=True</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#fusion_images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.fusion_images" title="Permalink to this definition">¶</a></dt>
@@ -434,6 +474,38 @@
 </div>
 </dd></dl>
 
+<dl class="function">
+<dt id="ipfml.processing.ipca_reconstruction">
+<code class="descclassname">ipfml.processing.</code><code class="descname">ipca_reconstruction</code><span class="sig-paren">(</span><em>image</em>, <em>components</em>, <em>_batch_size=25</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#ipca_reconstruction"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.ipca_reconstruction" title="Permalink to this definition">¶</a></dt>
+<dd><p>Reconstruct an image from SVD compression using specific number of components to use and batch size</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>image</strong> – PIL Image, Numpy array or path of 3D image</li>
+<li><strong>components</strong> – Number of components used for reconstruction</li>
+<li><strong>batch_size</strong> – Batch size used for learn (default 25)</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Reconstructed image</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">PIL</span> <span class="k">import</span> <span class="n">Image</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="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="n">image_values</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">reconstructed_image</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">ipca_reconstruction</span><span class="p">(</span><span class="n">image_values</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">reconstructed_image</span><span class="o">.</span><span class="n">shape</span>
+<span class="go">(200, 200)</span>
+</pre></div>
+</div>
+</dd></dl>
+
 <dl class="function">
 <dt id="ipfml.processing.rgb_to_LAB_L_bits">
 <code class="descclassname">ipfml.processing.</code><code class="descname">rgb_to_LAB_L_bits</code><span class="sig-paren">(</span><em>image</em>, <em>interval</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#rgb_to_LAB_L_bits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.rgb_to_LAB_L_bits" title="Permalink to this definition">¶</a></dt>
@@ -580,6 +652,37 @@
 </div>
 </dd></dl>
 
+<dl class="function">
+<dt id="ipfml.processing.svd_reconstruction">
+<code class="descclassname">ipfml.processing.</code><code class="descname">svd_reconstruction</code><span class="sig-paren">(</span><em>image</em>, <em>interval</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#svd_reconstruction"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.svd_reconstruction" title="Permalink to this definition">¶</a></dt>
+<dd><p>Reconstruct an image from SVD compression using specific interval of Singular Values</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>image</strong> – PIL Image, Numpy array or path of 3D image</li>
+<li><strong>interval</strong> – Interval used for reconstruction</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Reconstructed image</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">PIL</span> <span class="k">import</span> <span class="n">Image</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="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="n">image_values</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">reconstructed_image</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">svd_reconstruction</span><span class="p">(</span><span class="n">image_values</span><span class="p">,</span> <span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="mi">200</span><span class="p">))</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">reconstructed_image</span><span class="o">.</span><span class="n">shape</span>
+<span class="go">(200, 200)</span>
+</pre></div>
+</div>
+</dd></dl>
+
 </div>
 
 

+ 2 - 2
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.9 documentation</title>
+  <title>ipfml.utils &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -58,7 +58,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

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.9 documentation</title>
+  <title>Python Module Index &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -59,7 +59,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </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.9 documentation</title>
+  <title>Search &mdash; IPFML v0.4.0 documentation</title>
   
 
   
@@ -56,7 +56,7 @@
             
             
               <div class="version">
-                0.3.9
+                0.4.0
               </div>
             
           

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


+ 2 - 2
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.9'
+version = '0.4.0'
 # The full version, including alpha/beta/rc tags
-release = 'v0.3.9'
+release = 'v0.4.0'
 
 
 # -- General configuration ---------------------------------------------------

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

@@ -10,17 +10,20 @@ ipfml.processing
    .. autosummary::
    
       divide_in_blocks
+      fast_ica_reconstruction
       fusion_images
       get_LAB_L_SVD
       get_LAB_L_SVD_U
       get_LAB_L_SVD_V
       get_LAB_L_SVD_s
       get_mscn_coefficients
+      ipca_reconstruction
       rgb_to_LAB_L_bits
       rgb_to_LAB_L_low_bits
       rgb_to_grey_low_bits
       rgb_to_mscn
       rotate_image
+      svd_reconstruction
    
    
 

+ 105 - 1
ipfml/processing.py

@@ -8,10 +8,12 @@ import random
 import cv2
 from skimage import transform, color
 from scipy import signal
+from numpy.linalg import svd
+from sklearn.decomposition import FastICA, IncrementalPCA
 
 import numpy as np
 import ipfml.metrics as metrics
-from ipfml import exceptions
+from ipfml.exceptions import NumpyShapeComparisonException
 
 import os
 
@@ -476,3 +478,105 @@ def get_mscn_coefficients(image):
     sigma = np.sqrt(abs((sigma - mu_sq)))
     structdis = (imdist - mu) / (sigma + 1)
     return structdis
+
+
+def svd_reconstruction(image, interval):
+    """Reconstruct an image from SVD compression using specific interval of Singular Values
+
+    Args:
+        image: PIL Image, Numpy array or path of 3D image
+        interval: Interval used for reconstruction
+
+    Returns:
+        Reconstructed image
+
+    Example:
+
+    >>> from PIL import Image
+    >>> import numpy as np
+    >>> from ipfml import processing
+    >>> image_values = Image.open('./images/test_img.png')
+    >>> reconstructed_image = processing.svd_reconstruction(image_values, (100, 200))
+    >>> reconstructed_image.shape
+    (200, 200)
+    """
+
+    begin, end = interval
+    lab_img = metrics.get_LAB_L(image)
+    lab_img = np.array(lab_img, 'uint8')
+
+    U, s, V = svd(lab_img, full_matrices=True)
+
+    # reconstruction using specific interval
+    smat = np.zeros((end - begin, end - begin), dtype=complex)
+    smat[:, :] = np.diag(s[begin:end])
+    output_img = np.dot(U[:, begin:end], np.dot(smat, V[begin:end, :]))
+
+    return output_img
+
+
+def fast_ica_reconstruction(image, components):
+    """Reconstruct an image from SVD compression using specific number of components to use
+
+    Args:
+        image: PIL Image, Numpy array or path of 3D image
+        components: Number of components used for reconstruction
+
+    Returns:
+        Reconstructed image
+
+    Example:
+
+    >>> from PIL import Image
+    >>> import numpy as np
+    >>> from ipfml import processing
+    >>> image_values = Image.open('./images/test_img.png')
+    >>> reconstructed_image = processing.fast_ica_reconstruction(image_values, 25)
+    >>> reconstructed_image.shape
+    (200, 200)
+    """
+
+    lab_img = metrics.get_LAB_L(image)
+    lab_img = np.array(lab_img, 'uint8')
+
+    ica = FastICA(n_components=50)
+    # run ICA on image
+    ica.fit(lab_img)
+    # reconstruct image with independent components
+    image_ica = ica.fit_transform(lab_img)
+    restored_image = ica.inverse_transform(image_ica)
+
+    return restored_image
+
+
+def ipca_reconstruction(image, components, _batch_size=25):
+    """Reconstruct an image from SVD compression using specific number of components to use and batch size
+
+    Args:
+        image: PIL Image, Numpy array or path of 3D image
+        components: Number of components used for reconstruction
+        batch_size: Batch size used for learn (default 25)
+
+    Returns:
+        Reconstructed image
+
+    Example:
+
+    >>> from PIL import Image
+    >>> import numpy as np
+    >>> from ipfml import processing
+    >>> image_values = Image.open('./images/test_img.png')
+    >>> reconstructed_image = processing.ipca_reconstruction(image_values, 20)
+    >>> reconstructed_image.shape
+    (200, 200)
+    """
+    lab_img = metrics.get_LAB_L(image)
+    lab_img = np.array(lab_img, 'uint8')
+
+    transformer = IncrementalPCA(
+        n_components=components, batch_size=_batch_size)
+
+    transformed_image = transformer.fit_transform(lab_img)
+    restored_image = transformer.inverse_transform(transformed_image)
+
+    return restored_image

+ 1 - 1
setup.py

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