ipfml.processing.html 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>ipfml.processing &mdash; IPFML v0.4.0 documentation</title>
  8. <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  9. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  10. <link rel="index" title="Index" href="../genindex.html" />
  11. <link rel="search" title="Search" href="../search.html" />
  12. <link rel="next" title="ipfml.utils" href="ipfml.utils.html" />
  13. <link rel="prev" title="ipfml.metrics" href="ipfml.metrics.html" />
  14. <script src="../_static/js/modernizr.min.js"></script>
  15. </head>
  16. <body class="wy-body-for-nav">
  17. <div class="wy-grid-for-nav">
  18. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  19. <div class="wy-side-scroll">
  20. <div class="wy-side-nav-search">
  21. <a href="../index.html" class="icon icon-home"> IPFML
  22. </a>
  23. <div class="version">
  24. 0.4.0
  25. </div>
  26. <div role="search">
  27. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  28. <input type="text" name="q" placeholder="Search docs" />
  29. <input type="hidden" name="check_keywords" value="yes" />
  30. <input type="hidden" name="area" value="default" />
  31. </form>
  32. </div>
  33. </div>
  34. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  35. <p class="caption"><span class="caption-text">Contents:</span></p>
  36. <ul class="current">
  37. <li class="toctree-l1"><a class="reference internal" href="../description.html">Description</a></li>
  38. <li class="toctree-l1 current"><a class="reference internal" href="../ipfml.html">Documentation</a><ul class="current">
  39. <li class="toctree-l2"><a class="reference internal" href="ipfml.metrics.html">ipfml.metrics</a></li>
  40. <li class="toctree-l2 current"><a class="current reference internal" href="#">ipfml.processing</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="ipfml.utils.html">ipfml.utils</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="ipfml.exceptions.html">ipfml.exceptions</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-filters">ipfml.filters</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-iqa">ipfml.iqa</a></li>
  45. </ul>
  46. </li>
  47. <li class="toctree-l1"><a class="reference internal" href="../examples.html">Examples</a></li>
  48. <li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributing</a></li>
  49. </ul>
  50. </div>
  51. </div>
  52. </nav>
  53. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  54. <nav class="wy-nav-top" aria-label="top navigation">
  55. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  56. <a href="../index.html">IPFML</a>
  57. </nav>
  58. <div class="wy-nav-content">
  59. <div class="rst-content">
  60. <div role="navigation" aria-label="breadcrumbs navigation">
  61. <ul class="wy-breadcrumbs">
  62. <li><a href="../index.html">Docs</a> &raquo;</li>
  63. <li><a href="../ipfml.html">Documentation</a> &raquo;</li>
  64. <li>ipfml.processing</li>
  65. <li class="wy-breadcrumbs-aside">
  66. <a href="https://github.com/jbuisine/IPFML/blob/master/docs/source/ipfml/ipfml.processing.rst" class="fa fa-github"> Edit on GitHub</a>
  67. </li>
  68. </ul>
  69. <hr/>
  70. </div>
  71. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  72. <div itemprop="articleBody">
  73. <div class="section" id="module-ipfml.processing">
  74. <span id="ipfml-processing"></span><h1>ipfml.processing<a class="headerlink" href="#module-ipfml.processing" title="Permalink to this headline">¶</a></h1>
  75. <p>Functions to quickly extract reduced information from image</p>
  76. <p class="rubric">Functions</p>
  77. <table border="1" class="longtable docutils">
  78. <colgroup>
  79. <col width="10%" />
  80. <col width="90%" />
  81. </colgroup>
  82. <tbody valign="top">
  83. <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>
  84. <td>Divide image into equal size blocks</td>
  85. </tr>
  86. <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>
  87. <td>Reconstruct an image from SVD compression using specific number of components to use</td>
  88. </tr>
  89. <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>
  90. <td>Fusion array of images into single image</td>
  91. </tr>
  92. <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>
  93. <td>Returns Singular values from LAB L Image information</td>
  94. </tr>
  95. <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>
  96. <td>Returns U SVD from L of LAB Image information</td>
  97. </tr>
  98. <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>
  99. <td>Returns V SVD from L of LAB Image information</td>
  100. </tr>
  101. <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>
  102. <td>Returns s (Singular values) SVD from L of LAB Image information</td>
  103. </tr>
  104. <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>
  105. <td>Compute the Mean Substracted Constrast Normalized coefficients of an image</td>
  106. </tr>
  107. <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>
  108. <td>Reconstruct an image from SVD compression using specific number of components to use and batch size</td>
  109. </tr>
  110. <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>
  111. <td>Returns only bits from LAB L canal specified into the interval</td>
  112. </tr>
  113. <tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.rgb_to_LAB_L_low_bits" title="ipfml.processing.rgb_to_LAB_L_low_bits"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rgb_to_LAB_L_low_bits</span></code></a>(image[,&nbsp;nb_bits])</td>
  114. <td>Convert RGB Image into Lab L channel image using only 4 low bits values</td>
  115. </tr>
  116. <tr class="row-even"><td><a class="reference internal" href="#ipfml.processing.rgb_to_grey_low_bits" title="ipfml.processing.rgb_to_grey_low_bits"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rgb_to_grey_low_bits</span></code></a>(image[,&nbsp;nb_bits])</td>
  117. <td>Convert RGB Image into grey image using only 4 low bits values</td>
  118. </tr>
  119. <tr class="row-odd"><td><a class="reference internal" href="#ipfml.processing.rgb_to_mscn" title="ipfml.processing.rgb_to_mscn"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rgb_to_mscn</span></code></a>(image)</td>
  120. <td>Convert RGB Image into Mean Subtracted Contrast Normalized (MSCN)</td>
  121. </tr>
  122. <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>
  123. <td>Rotate image using specific angle</td>
  124. </tr>
  125. <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>
  126. <td>Reconstruct an image from SVD compression using specific interval of Singular Values</td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. <dl class="function">
  131. <dt id="ipfml.processing.divide_in_blocks">
  132. <code class="descclassname">ipfml.processing.</code><code class="descname">divide_in_blocks</code><span class="sig-paren">(</span><em>image</em>, <em>block_size</em>, <em>pil=True</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#divide_in_blocks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.divide_in_blocks" title="Permalink to this definition">¶</a></dt>
  133. <dd><p>Divide image into equal size blocks</p>
  134. <table class="docutils field-list" frame="void" rules="none">
  135. <col class="field-name" />
  136. <col class="field-body" />
  137. <tbody valign="top">
  138. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  139. <li><strong>image</strong> – PIL Image or Numpy array</li>
  140. <li><strong>block</strong> – tuple (width, height) representing the size of each dimension of the block</li>
  141. <li><strong>pil</strong> – block type returned as PIL Image (default True)</li>
  142. </ul>
  143. </td>
  144. </tr>
  145. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">list containing all 2D Numpy blocks (in RGB or not)</p>
  146. </td>
  147. </tr>
  148. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – If <cite>image_width</cite> or <cite>image_height</cite> are not compatible to produce correct block sizes</p>
  149. </td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. <p>Example:</p>
  154. <div class="highlight-default notranslate"><div class="highlight"><pre><span></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>
  155. <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>
  156. <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>
  157. <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>
  158. <span class="gp">&gt;&gt;&gt; </span><span class="n">image_values</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">randint</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">800</span><span class="p">,</span> <span class="mi">800</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
  159. <span class="gp">&gt;&gt;&gt; </span><span class="n">blocks</span> <span class="o">=</span> <span class="n">divide_in_blocks</span><span class="p">(</span><span class="n">image_values</span><span class="p">,</span> <span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">))</span>
  160. <span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">blocks</span><span class="p">)</span>
  161. <span class="go">1600</span>
  162. <span class="gp">&gt;&gt;&gt; </span><span class="n">blocks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">width</span>
  163. <span class="go">20</span>
  164. <span class="gp">&gt;&gt;&gt; </span><span class="n">blocks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">height</span>
  165. <span class="go">20</span>
  166. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_l</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>
  167. <span class="gp">&gt;&gt;&gt; </span><span class="n">L</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_l</span><span class="p">)</span>
  168. <span class="gp">&gt;&gt;&gt; </span><span class="n">blocks_L</span> <span class="o">=</span> <span class="n">divide_in_blocks</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  169. <span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">blocks_L</span><span class="p">)</span>
  170. <span class="go">4</span>
  171. <span class="gp">&gt;&gt;&gt; </span><span class="n">blocks_L</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">width</span>
  172. <span class="go">100</span>
  173. </pre></div>
  174. </div>
  175. </dd></dl>
  176. <dl class="function">
  177. <dt id="ipfml.processing.fast_ica_reconstruction">
  178. <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>
  179. <dd><p>Reconstruct an image from SVD compression using specific number of components to use</p>
  180. <table class="docutils field-list" frame="void" rules="none">
  181. <col class="field-name" />
  182. <col class="field-body" />
  183. <tbody valign="top">
  184. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  185. <li><strong>image</strong> – PIL Image, Numpy array or path of 3D image</li>
  186. <li><strong>components</strong> – Number of components used for reconstruction</li>
  187. </ul>
  188. </td>
  189. </tr>
  190. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Reconstructed image</p>
  191. </td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. <p>Example:</p>
  196. <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>
  197. <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>
  198. <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>
  199. <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>
  200. <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>
  201. <span class="gp">&gt;&gt;&gt; </span><span class="n">reconstructed_image</span><span class="o">.</span><span class="n">shape</span>
  202. <span class="go">(200, 200)</span>
  203. </pre></div>
  204. </div>
  205. </dd></dl>
  206. <dl class="function">
  207. <dt id="ipfml.processing.fusion_images">
  208. <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>
  209. <dd><p>Fusion array of images into single image</p>
  210. <table class="docutils field-list" frame="void" rules="none">
  211. <col class="field-name" />
  212. <col class="field-body" />
  213. <tbody valign="top">
  214. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  215. <li><strong>images</strong> – array of images (PIL Image or Numpy array)</li>
  216. <li><strong>pil</strong> – block type returned as PIL Image (default True)</li>
  217. </ul>
  218. </td>
  219. </tr>
  220. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">merged image from array of images</p>
  221. </td>
  222. </tr>
  223. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  224. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – if <cite>images</cite> is not an array or is empty</li>
  225. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">NumpyShapeComparisonException</span></code> – if <cite>images</cite> array contains images with different shapes</li>
  226. </ul>
  227. </td>
  228. </tr>
  229. </tbody>
  230. </table>
  231. <p>Example:</p>
  232. <div class="highlight-default notranslate"><div class="highlight"><pre><span></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>
  233. <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>
  234. <span class="gp">&gt;&gt;&gt; </span><span class="n">image_values_1</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">randint</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">800</span><span class="p">,</span> <span class="mi">800</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
  235. <span class="gp">&gt;&gt;&gt; </span><span class="n">image_values_2</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">randint</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">800</span><span class="p">,</span> <span class="mi">800</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
  236. <span class="gp">&gt;&gt;&gt; </span><span class="n">merged_image</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">fusion_images</span><span class="p">([</span><span class="n">image_values_1</span><span class="p">,</span> <span class="n">image_values_2</span><span class="p">],</span> <span class="n">pil</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
  237. <span class="gp">&gt;&gt;&gt; </span><span class="n">merged_image</span><span class="o">.</span><span class="n">shape</span>
  238. <span class="go">(800, 800, 3)</span>
  239. </pre></div>
  240. </div>
  241. </dd></dl>
  242. <dl class="function">
  243. <dt id="ipfml.processing.get_LAB_L_SVD">
  244. <code class="descclassname">ipfml.processing.</code><code class="descname">get_LAB_L_SVD</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#get_LAB_L_SVD"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.get_LAB_L_SVD" title="Permalink to this definition">¶</a></dt>
  245. <dd><p>Returns Singular values from LAB L Image information</p>
  246. <table class="docutils field-list" frame="void" rules="none">
  247. <col class="field-name" />
  248. <col class="field-body" />
  249. <tbody valign="top">
  250. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  251. </tr>
  252. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U, s, V information obtained from SVD compression using Lab</td>
  253. </tr>
  254. </tbody>
  255. </table>
  256. <p>Example:</p>
  257. <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>
  258. <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>
  259. <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>
  260. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="n">V</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">get_LAB_L_SVD</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  261. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  262. <span class="go">(200, 200)</span>
  263. <span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
  264. <span class="go">200</span>
  265. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  266. <span class="go">(200, 200)</span>
  267. </pre></div>
  268. </div>
  269. </dd></dl>
  270. <dl class="function">
  271. <dt id="ipfml.processing.get_LAB_L_SVD_U">
  272. <code class="descclassname">ipfml.processing.</code><code class="descname">get_LAB_L_SVD_U</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#get_LAB_L_SVD_U"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.get_LAB_L_SVD_U" title="Permalink to this definition">¶</a></dt>
  273. <dd><p>Returns U SVD from L of LAB Image information</p>
  274. <table class="docutils field-list" frame="void" rules="none">
  275. <col class="field-name" />
  276. <col class="field-body" />
  277. <tbody valign="top">
  278. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  279. </tr>
  280. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U matrix of SVD compression</td>
  281. </tr>
  282. </tbody>
  283. </table>
  284. <p>Example:</p>
  285. <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>
  286. <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>
  287. <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>
  288. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">get_LAB_L_SVD_U</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  289. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  290. <span class="go">(200, 200)</span>
  291. </pre></div>
  292. </div>
  293. </dd></dl>
  294. <dl class="function">
  295. <dt id="ipfml.processing.get_LAB_L_SVD_V">
  296. <code class="descclassname">ipfml.processing.</code><code class="descname">get_LAB_L_SVD_V</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#get_LAB_L_SVD_V"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.get_LAB_L_SVD_V" title="Permalink to this definition">¶</a></dt>
  297. <dd><p>Returns V SVD from L of LAB Image information</p>
  298. <table class="docutils field-list" frame="void" rules="none">
  299. <col class="field-name" />
  300. <col class="field-body" />
  301. <tbody valign="top">
  302. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  303. </tr>
  304. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">V matrix of SVD compression</td>
  305. </tr>
  306. </tbody>
  307. </table>
  308. <p>Example:</p>
  309. <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>
  310. <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>
  311. <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>
  312. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">get_LAB_L_SVD_V</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  313. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  314. <span class="go">(200, 200)</span>
  315. </pre></div>
  316. </div>
  317. </dd></dl>
  318. <dl class="function">
  319. <dt id="ipfml.processing.get_LAB_L_SVD_s">
  320. <code class="descclassname">ipfml.processing.</code><code class="descname">get_LAB_L_SVD_s</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#get_LAB_L_SVD_s"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.get_LAB_L_SVD_s" title="Permalink to this definition">¶</a></dt>
  321. <dd><p>Returns s (Singular values) SVD from L of LAB Image information</p>
  322. <table class="docutils field-list" frame="void" rules="none">
  323. <col class="field-name" />
  324. <col class="field-body" />
  325. <tbody valign="top">
  326. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  327. </tr>
  328. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">vector of singular values</td>
  329. </tr>
  330. </tbody>
  331. </table>
  332. <p>Example:</p>
  333. <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>
  334. <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>
  335. <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>
  336. <span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">get_LAB_L_SVD_s</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  337. <span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
  338. <span class="go">200</span>
  339. </pre></div>
  340. </div>
  341. </dd></dl>
  342. <dl class="function">
  343. <dt id="ipfml.processing.get_mscn_coefficients">
  344. <code class="descclassname">ipfml.processing.</code><code class="descname">get_mscn_coefficients</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#get_mscn_coefficients"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.get_mscn_coefficients" title="Permalink to this definition">¶</a></dt>
  345. <dd><p>Compute the Mean Substracted Constrast Normalized coefficients of an image</p>
  346. <table class="docutils field-list" frame="void" rules="none">
  347. <col class="field-name" />
  348. <col class="field-body" />
  349. <tbody valign="top">
  350. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>image</strong> – PIL Image, Numpy array or path of image</p>
  351. </td>
  352. </tr>
  353. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">MSCN coefficients</p>
  354. </td>
  355. </tr>
  356. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  357. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">FileNotFoundError</span></code> – If <cite>image</cite> is set as str path and image was not found</li>
  358. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – If <cite>image</cite> numpy shape are not correct</li>
  359. </ul>
  360. </td>
  361. </tr>
  362. </tbody>
  363. </table>
  364. <p>Example:</p>
  365. <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>
  366. <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>
  367. <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>
  368. <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>
  369. <span class="gp">&gt;&gt;&gt; </span><span class="n">mscn_coefficients</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">get_mscn_coefficients</span><span class="p">(</span><span class="n">image_values</span><span class="p">)</span>
  370. <span class="gp">&gt;&gt;&gt; </span><span class="n">mscn_coefficients</span><span class="o">.</span><span class="n">shape</span>
  371. <span class="go">(200, 200)</span>
  372. </pre></div>
  373. </div>
  374. </dd></dl>
  375. <dl class="function">
  376. <dt id="ipfml.processing.ipca_reconstruction">
  377. <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>
  378. <dd><p>Reconstruct an image from SVD compression using specific number of components to use and batch size</p>
  379. <table class="docutils field-list" frame="void" rules="none">
  380. <col class="field-name" />
  381. <col class="field-body" />
  382. <tbody valign="top">
  383. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  384. <li><strong>image</strong> – PIL Image, Numpy array or path of 3D image</li>
  385. <li><strong>components</strong> – Number of components used for reconstruction</li>
  386. <li><strong>batch_size</strong> – Batch size used for learn (default 25)</li>
  387. </ul>
  388. </td>
  389. </tr>
  390. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Reconstructed image</p>
  391. </td>
  392. </tr>
  393. </tbody>
  394. </table>
  395. <p>Example:</p>
  396. <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>
  397. <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>
  398. <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>
  399. <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>
  400. <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>
  401. <span class="gp">&gt;&gt;&gt; </span><span class="n">reconstructed_image</span><span class="o">.</span><span class="n">shape</span>
  402. <span class="go">(200, 200)</span>
  403. </pre></div>
  404. </div>
  405. </dd></dl>
  406. <dl class="function">
  407. <dt id="ipfml.processing.rgb_to_LAB_L_bits">
  408. <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>
  409. <dd><p>Returns only bits from LAB L canal specified into the interval</p>
  410. <table class="docutils field-list" frame="void" rules="none">
  411. <col class="field-name" />
  412. <col class="field-body" />
  413. <tbody valign="top">
  414. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  415. <li><strong>image</strong> – image to convert using this interval of bits value to keep</li>
  416. <li><strong>interval</strong> – (begin, end) of bits values</li>
  417. </ul>
  418. </td>
  419. </tr>
  420. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with reduced values</p>
  421. </td>
  422. </tr>
  423. </tbody>
  424. </table>
  425. <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>
  426. <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>
  427. <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>
  428. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_Lab_l_img</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rgb_to_LAB_L_bits</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">6</span><span class="p">))</span>
  429. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_Lab_l_img</span><span class="o">.</span><span class="n">shape</span>
  430. <span class="go">(200, 200)</span>
  431. </pre></div>
  432. </div>
  433. </dd></dl>
  434. <dl class="function">
  435. <dt id="ipfml.processing.rgb_to_LAB_L_low_bits">
  436. <code class="descclassname">ipfml.processing.</code><code class="descname">rgb_to_LAB_L_low_bits</code><span class="sig-paren">(</span><em>image</em>, <em>nb_bits=4</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#rgb_to_LAB_L_low_bits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.rgb_to_LAB_L_low_bits" title="Permalink to this definition">¶</a></dt>
  437. <dd><p>Convert RGB Image into Lab L channel image using only 4 low bits values</p>
  438. <table class="docutils field-list" frame="void" rules="none">
  439. <col class="field-name" />
  440. <col class="field-body" />
  441. <tbody valign="top">
  442. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  443. <li><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</li>
  444. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep (default 4)</li>
  445. </ul>
  446. </td>
  447. </tr>
  448. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with low bits information kept</p>
  449. </td>
  450. </tr>
  451. </tbody>
  452. </table>
  453. <p>Example:</p>
  454. <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>
  455. <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>
  456. <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>
  457. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_Lab_l_img</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rgb_to_LAB_L_low_bits</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
  458. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_Lab_l_img</span><span class="o">.</span><span class="n">shape</span>
  459. <span class="go">(200, 200)</span>
  460. </pre></div>
  461. </div>
  462. </dd></dl>
  463. <dl class="function">
  464. <dt id="ipfml.processing.rgb_to_grey_low_bits">
  465. <code class="descclassname">ipfml.processing.</code><code class="descname">rgb_to_grey_low_bits</code><span class="sig-paren">(</span><em>image</em>, <em>nb_bits=4</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#rgb_to_grey_low_bits"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.rgb_to_grey_low_bits" title="Permalink to this definition">¶</a></dt>
  466. <dd><p>Convert RGB Image into grey image using only 4 low bits values</p>
  467. <table class="docutils field-list" frame="void" rules="none">
  468. <col class="field-name" />
  469. <col class="field-body" />
  470. <tbody valign="top">
  471. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  472. <li><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</li>
  473. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep (default 4)</li>
  474. </ul>
  475. </td>
  476. </tr>
  477. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with low bits information kept</p>
  478. </td>
  479. </tr>
  480. </tbody>
  481. </table>
  482. <p>Example:</p>
  483. <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>
  484. <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>
  485. <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>
  486. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_grey_img</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rgb_to_grey_low_bits</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
  487. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_grey_img</span><span class="o">.</span><span class="n">shape</span>
  488. <span class="go">(200, 200)</span>
  489. </pre></div>
  490. </div>
  491. </dd></dl>
  492. <dl class="function">
  493. <dt id="ipfml.processing.rgb_to_mscn">
  494. <code class="descclassname">ipfml.processing.</code><code class="descname">rgb_to_mscn</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#rgb_to_mscn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.rgb_to_mscn" title="Permalink to this definition">¶</a></dt>
  495. <dd><p>Convert RGB Image into Mean Subtracted Contrast Normalized (MSCN)</p>
  496. <table class="docutils field-list" frame="void" rules="none">
  497. <col class="field-name" />
  498. <col class="field-body" />
  499. <tbody valign="top">
  500. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</td>
  501. </tr>
  502. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">2D Numpy array with MSCN information</td>
  503. </tr>
  504. </tbody>
  505. </table>
  506. <p>Example:</p>
  507. <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>
  508. <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>
  509. <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>
  510. <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>
  511. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span><span class="o">.</span><span class="n">shape</span>
  512. <span class="go">(200, 200)</span>
  513. </pre></div>
  514. </div>
  515. </dd></dl>
  516. <dl class="function">
  517. <dt id="ipfml.processing.rotate_image">
  518. <code class="descclassname">ipfml.processing.</code><code class="descname">rotate_image</code><span class="sig-paren">(</span><em>image</em>, <em>angle=90</em>, <em>pil=True</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/processing.html#rotate_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.processing.rotate_image" title="Permalink to this definition">¶</a></dt>
  519. <dd><p>Rotate image using specific angle</p>
  520. <table class="docutils field-list" frame="void" rules="none">
  521. <col class="field-name" />
  522. <col class="field-body" />
  523. <tbody valign="top">
  524. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  525. <li><strong>image</strong> – PIL Image or Numpy array</li>
  526. <li><strong>angle</strong> – Angle value of the rotation</li>
  527. <li><strong>pil</strong> – block type returned as PIL Image (default True)</li>
  528. </ul>
  529. </td>
  530. </tr>
  531. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Image with rotation applied</p>
  532. </td>
  533. </tr>
  534. </tbody>
  535. </table>
  536. <p>Example:</p>
  537. <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>
  538. <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>
  539. <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>
  540. <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>
  541. <span class="gp">&gt;&gt;&gt; </span><span class="n">rotated_image</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rotate_image</span><span class="p">(</span><span class="n">image_values</span><span class="p">,</span> <span class="mi">90</span><span class="p">,</span> <span class="n">pil</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
  542. <span class="gp">&gt;&gt;&gt; </span><span class="n">rotated_image</span><span class="o">.</span><span class="n">shape</span>
  543. <span class="go">(200, 200, 3)</span>
  544. </pre></div>
  545. </div>
  546. </dd></dl>
  547. <dl class="function">
  548. <dt id="ipfml.processing.svd_reconstruction">
  549. <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>
  550. <dd><p>Reconstruct an image from SVD compression using specific interval of Singular Values</p>
  551. <table class="docutils field-list" frame="void" rules="none">
  552. <col class="field-name" />
  553. <col class="field-body" />
  554. <tbody valign="top">
  555. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  556. <li><strong>image</strong> – PIL Image, Numpy array or path of 3D image</li>
  557. <li><strong>interval</strong> – Interval used for reconstruction</li>
  558. </ul>
  559. </td>
  560. </tr>
  561. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Reconstructed image</p>
  562. </td>
  563. </tr>
  564. </tbody>
  565. </table>
  566. <p>Example:</p>
  567. <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>
  568. <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>
  569. <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>
  570. <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>
  571. <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>
  572. <span class="gp">&gt;&gt;&gt; </span><span class="n">reconstructed_image</span><span class="o">.</span><span class="n">shape</span>
  573. <span class="go">(200, 200)</span>
  574. </pre></div>
  575. </div>
  576. </dd></dl>
  577. </div>
  578. </div>
  579. </div>
  580. <footer>
  581. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  582. <a href="ipfml.utils.html" class="btn btn-neutral float-right" title="ipfml.utils" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
  583. <a href="ipfml.metrics.html" class="btn btn-neutral" title="ipfml.metrics" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  584. </div>
  585. <hr/>
  586. <div role="contentinfo">
  587. <p>
  588. &copy; Copyright 2019, Jérôme BUISINE
  589. </p>
  590. </div>
  591. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  592. </footer>
  593. </div>
  594. </div>
  595. </section>
  596. </div>
  597. <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
  598. <script type="text/javascript" src="../_static/jquery.js"></script>
  599. <script type="text/javascript" src="../_static/underscore.js"></script>
  600. <script type="text/javascript" src="../_static/doctools.js"></script>
  601. <script type="text/javascript" src="../_static/language_data.js"></script>
  602. <script type="text/javascript" src="../_static/js/theme.js"></script>
  603. <script type="text/javascript">
  604. jQuery(function () {
  605. SphinxRtdTheme.Navigation.enable(true);
  606. });
  607. </script>
  608. </body>
  609. </html>