ipfml.html 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  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>Documentation &mdash; IPFML v0.2.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="Examples" href="examples.html" />
  13. <link rel="prev" title="Description" href="description.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.2.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="current reference internal" href="#">Documentation</a><ul>
  39. <li class="toctree-l2"><a class="reference internal" href="#module-ipfml.metrics">ipfml.metrics</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="#module-ipfml.processing">ipfml.processing</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="#ipfml-filters">ipfml.filters</a><ul>
  42. <li class="toctree-l3"><a class="reference internal" href="#module-ipfml.filters.noise">ipfml.filters.noise</a></li>
  43. </ul>
  44. </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>Documentation</li>
  64. <li class="wy-breadcrumbs-aside">
  65. <a href="_sources/ipfml.rst.txt" rel="nofollow"> View page source</a>
  66. </li>
  67. </ul>
  68. <hr/>
  69. </div>
  70. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  71. <div itemprop="articleBody">
  72. <div class="section" id="documentation">
  73. <h1>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h1>
  74. <div class="section" id="module-ipfml.metrics">
  75. <span id="ipfml-metrics"></span><h2>ipfml.metrics<a class="headerlink" href="#module-ipfml.metrics" title="Permalink to this headline">¶</a></h2>
  76. <dl class="function">
  77. <dt id="ipfml.metrics.get_LAB">
  78. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_LAB</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_LAB" title="Permalink to this definition">¶</a></dt>
  79. <dd><p>Transforms RGB Image into Lab</p>
  80. <table class="docutils field-list" frame="void" rules="none">
  81. <col class="field-name" />
  82. <col class="field-body" />
  83. <tbody valign="top">
  84. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  85. </tr>
  86. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Lab information</td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. <p>Usage:</p>
  91. <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>
  92. <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>
  93. <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>
  94. <span class="gp">&gt;&gt;&gt; </span><span class="n">Lab</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_LAB</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  95. <span class="gp">&gt;&gt;&gt; </span><span class="n">Lab</span><span class="o">.</span><span class="n">shape</span>
  96. <span class="go">(200, 200, 3)</span>
  97. </pre></div>
  98. </div>
  99. </dd></dl>
  100. <dl class="function">
  101. <dt id="ipfml.metrics.get_LAB_L">
  102. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_LAB_L</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_LAB_L" title="Permalink to this definition">¶</a></dt>
  103. <dd><p>Transforms RGB Image into Lab and returns L</p>
  104. <table class="docutils field-list" frame="void" rules="none">
  105. <col class="field-name" />
  106. <col class="field-body" />
  107. <tbody valign="top">
  108. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  109. </tr>
  110. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The L chanel from Lab information</td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. <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>
  115. <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>
  116. <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>
  117. <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</span><span class="p">)</span>
  118. <span class="gp">&gt;&gt;&gt; </span><span class="n">L</span><span class="o">.</span><span class="n">shape</span>
  119. <span class="go">(200, 200)</span>
  120. </pre></div>
  121. </div>
  122. </dd></dl>
  123. <dl class="function">
  124. <dt id="ipfml.metrics.get_LAB_a">
  125. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_LAB_a</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_LAB_a" title="Permalink to this definition">¶</a></dt>
  126. <dd><p>Transforms RGB Image into LAB and returns a</p>
  127. <table class="docutils field-list" frame="void" rules="none">
  128. <col class="field-name" />
  129. <col class="field-body" />
  130. <tbody valign="top">
  131. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  132. </tr>
  133. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The a chanel from Lab information</td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. <p>Usage:</p>
  138. <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>
  139. <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>
  140. <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>
  141. <span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_LAB_a</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  142. <span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">shape</span>
  143. <span class="go">(200, 200)</span>
  144. </pre></div>
  145. </div>
  146. </dd></dl>
  147. <dl class="function">
  148. <dt id="ipfml.metrics.get_LAB_b">
  149. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_LAB_b</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_LAB_b" title="Permalink to this definition">¶</a></dt>
  150. <dd><p>Transforms RGB Image into LAB and returns b</p>
  151. <table class="docutils field-list" frame="void" rules="none">
  152. <col class="field-name" />
  153. <col class="field-body" />
  154. <tbody valign="top">
  155. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  156. </tr>
  157. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The b chanel from Lab information</td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. <p>Usage :</p>
  162. <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>
  163. <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>
  164. <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>
  165. <span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_LAB_b</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  166. <span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">shape</span>
  167. <span class="go">(200, 200)</span>
  168. </pre></div>
  169. </div>
  170. </dd></dl>
  171. <dl class="function">
  172. <dt id="ipfml.metrics.get_SVD">
  173. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_SVD</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_SVD" title="Permalink to this definition">¶</a></dt>
  174. <dd><p>Transforms Image using SVD compression</p>
  175. <table class="docutils field-list" frame="void" rules="none">
  176. <col class="field-name" />
  177. <col class="field-body" />
  178. <tbody valign="top">
  179. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert into SVD compression</td>
  180. </tr>
  181. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U, s, V obtained from SVD compression</td>
  182. </tr>
  183. </tbody>
  184. </table>
  185. <p>Usage:</p>
  186. <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>
  187. <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>
  188. <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>
  189. <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">metrics</span><span class="o">.</span><span class="n">get_SVD</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  190. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  191. <span class="go">(200, 200, 3)</span>
  192. <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>
  193. <span class="go">200</span>
  194. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  195. <span class="go">(200, 3, 3)</span>
  196. </pre></div>
  197. </div>
  198. </dd></dl>
  199. <dl class="function">
  200. <dt id="ipfml.metrics.get_SVD_U">
  201. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_SVD_U</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_SVD_U" title="Permalink to this definition">¶</a></dt>
  202. <dd><p>Transforms Image into SVD and returns only ‘U’ part</p>
  203. <table class="docutils field-list" frame="void" rules="none">
  204. <col class="field-name" />
  205. <col class="field-body" />
  206. <tbody valign="top">
  207. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  208. </tr>
  209. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U matrix from SVD compression</td>
  210. </tr>
  211. </tbody>
  212. </table>
  213. <p>Usage:</p>
  214. <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>
  215. <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>
  216. <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>
  217. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_SVD_U</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  218. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  219. <span class="go">(200, 200, 3)</span>
  220. </pre></div>
  221. </div>
  222. </dd></dl>
  223. <dl class="function">
  224. <dt id="ipfml.metrics.get_SVD_V">
  225. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_SVD_V</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_SVD_V" title="Permalink to this definition">¶</a></dt>
  226. <dd><p>Transforms Image into SVD and returns only ‘V’ part</p>
  227. <table class="docutils field-list" frame="void" rules="none">
  228. <col class="field-name" />
  229. <col class="field-body" />
  230. <tbody valign="top">
  231. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  232. </tr>
  233. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">V matrix obtained from SVD compression</td>
  234. </tr>
  235. </tbody>
  236. </table>
  237. <p>Usage :</p>
  238. <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>
  239. <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>
  240. <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>
  241. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_SVD_V</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  242. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  243. <span class="go">(200, 3, 3)</span>
  244. </pre></div>
  245. </div>
  246. </dd></dl>
  247. <dl class="function">
  248. <dt id="ipfml.metrics.get_SVD_s">
  249. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_SVD_s</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_SVD_s" title="Permalink to this definition">¶</a></dt>
  250. <dd><p>Transforms Image into SVD and returns only ‘s’ part</p>
  251. <table class="docutils field-list" frame="void" rules="none">
  252. <col class="field-name" />
  253. <col class="field-body" />
  254. <tbody valign="top">
  255. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  256. </tr>
  257. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">vector of singular values obtained from SVD compression</td>
  258. </tr>
  259. </tbody>
  260. </table>
  261. <p>Usage:</p>
  262. <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>
  263. <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>
  264. <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>
  265. <span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_SVD_s</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  266. <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>
  267. <span class="go">200</span>
  268. </pre></div>
  269. </div>
  270. </dd></dl>
  271. <dl class="function">
  272. <dt id="ipfml.metrics.get_XYZ">
  273. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_XYZ</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_XYZ" title="Permalink to this definition">¶</a></dt>
  274. <dd><p>Transforms RGB Image into XYZ</p>
  275. <table class="docutils field-list" frame="void" rules="none">
  276. <col class="field-name" />
  277. <col class="field-body" />
  278. <tbody valign="top">
  279. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  280. </tr>
  281. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">XYZ information obtained from transformation</td>
  282. </tr>
  283. </tbody>
  284. </table>
  285. <p>Usage:</p>
  286. <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>
  287. <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>
  288. <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>
  289. <span class="gp">&gt;&gt;&gt; </span><span class="n">metrics</span><span class="o">.</span><span class="n">get_XYZ</span><span class="p">(</span><span class="n">img</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span>
  290. <span class="go">(200, 200, 3)</span>
  291. </pre></div>
  292. </div>
  293. </dd></dl>
  294. <dl class="function">
  295. <dt id="ipfml.metrics.get_XYZ_X">
  296. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_XYZ_X</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_XYZ_X" title="Permalink to this definition">¶</a></dt>
  297. <dd><p>Transforms RGB Image into XYZ and returns X</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> – image to convert</td>
  303. </tr>
  304. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The X chanel from XYZ information</td>
  305. </tr>
  306. </tbody>
  307. </table>
  308. <p>Usage:</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">metrics</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">x</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_XYZ_X</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">x</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.metrics.get_XYZ_Y">
  320. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_XYZ_Y</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_XYZ_Y" title="Permalink to this definition">¶</a></dt>
  321. <dd><p>Transforms RGB Image into XYZ and returns Y</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> – image to convert</td>
  327. </tr>
  328. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The Y chanel from XYZ information</td>
  329. </tr>
  330. </tbody>
  331. </table>
  332. <p>Usage:</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">metrics</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">y</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_XYZ_Y</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  337. <span class="gp">&gt;&gt;&gt; </span><span class="n">y</span><span class="o">.</span><span class="n">shape</span>
  338. <span class="go">(200, 200)</span>
  339. </pre></div>
  340. </div>
  341. </dd></dl>
  342. <dl class="function">
  343. <dt id="ipfml.metrics.get_XYZ_Z">
  344. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_XYZ_Z</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_XYZ_Z" title="Permalink to this definition">¶</a></dt>
  345. <dd><p>Transforms RGB Image into XYZ and returns Z</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"><strong>image</strong> – image to convert</td>
  351. </tr>
  352. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The Z chanel from XYZ information</td>
  353. </tr>
  354. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – If <cite>nb_bits</cite> has unexpected value. <cite>nb_bits</cite> needs to be in interval [1, 8].</td>
  355. </tr>
  356. </tbody>
  357. </table>
  358. <p>Usage:</p>
  359. <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>
  360. <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>
  361. <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>
  362. <span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_XYZ_Z</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  363. <span class="gp">&gt;&gt;&gt; </span><span class="n">z</span><span class="o">.</span><span class="n">shape</span>
  364. <span class="go">(200, 200)</span>
  365. </pre></div>
  366. </div>
  367. </dd></dl>
  368. <dl class="function">
  369. <dt id="ipfml.metrics.get_bits_img">
  370. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_bits_img</code><span class="sig-paren">(</span><em>image</em>, <em>interval</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_bits_img" title="Permalink to this definition">¶</a></dt>
  371. <dd><p>Returns only bits specified into the interval</p>
  372. <table class="docutils field-list" frame="void" rules="none">
  373. <col class="field-name" />
  374. <col class="field-body" />
  375. <tbody valign="top">
  376. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  377. <li><strong>image</strong> – image to convert using this interval of bits value to keep</li>
  378. <li><strong>interval</strong> – (begin, end) of bits values</li>
  379. </ul>
  380. </td>
  381. </tr>
  382. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Numpy array with reduced values</p>
  383. </td>
  384. </tr>
  385. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  386. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – If min value from interval is not &gt;= 1.</li>
  387. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – If max value from interval is not &lt;= 8.</li>
  388. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> – If min value from interval &gt;= max value.</li>
  389. </ul>
  390. </td>
  391. </tr>
  392. </tbody>
  393. </table>
  394. <p>Usage:</p>
  395. <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>
  396. <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>
  397. <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>
  398. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_img</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_bits_img</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">5</span><span class="p">))</span>
  399. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_img</span><span class="o">.</span><span class="n">shape</span>
  400. <span class="go">(200, 200, 3)</span>
  401. </pre></div>
  402. </div>
  403. </dd></dl>
  404. <dl class="function">
  405. <dt id="ipfml.metrics.get_low_bits_img">
  406. <code class="descclassname">ipfml.metrics.</code><code class="descname">get_low_bits_img</code><span class="sig-paren">(</span><em>image</em>, <em>nb_bits=4</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.get_low_bits_img" title="Permalink to this definition">¶</a></dt>
  407. <dd><p>Returns Image or Numpy array with data information reduced using only low bits</p>
  408. <table class="docutils field-list" frame="void" rules="none">
  409. <col class="field-name" />
  410. <col class="field-body" />
  411. <tbody valign="top">
  412. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  413. <li><strong>image</strong> – image to convert</li>
  414. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep</li>
  415. </ul>
  416. </td>
  417. </tr>
  418. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Numpy array with reduced values</p>
  419. </td>
  420. </tr>
  421. </tbody>
  422. </table>
  423. <p>Usage:</p>
  424. <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>
  425. <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>
  426. <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>
  427. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_img</span> <span class="o">=</span> <span class="n">metrics</span><span class="o">.</span><span class="n">get_low_bits_img</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
  428. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_img</span><span class="o">.</span><span class="n">shape</span>
  429. <span class="go">(200, 200, 3)</span>
  430. </pre></div>
  431. </div>
  432. </dd></dl>
  433. <dl class="function">
  434. <dt id="ipfml.metrics.gray_to_mscn">
  435. <code class="descclassname">ipfml.metrics.</code><code class="descname">gray_to_mscn</code><span class="sig-paren">(</span><em>image</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.metrics.gray_to_mscn" title="Permalink to this definition">¶</a></dt>
  436. <dd><p>Convert Grayscale Image into Mean Subtracted Contrast Normalized (MSCN)</p>
  437. <table class="docutils field-list" frame="void" rules="none">
  438. <col class="field-name" />
  439. <col class="field-body" />
  440. <tbody valign="top">
  441. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – grayscale image</td>
  442. </tr>
  443. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">MSCN matrix obtained from transformation</td>
  444. </tr>
  445. </tbody>
  446. </table>
  447. <p>Usage:</p>
  448. <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>
  449. <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>
  450. <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>
  451. <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>
  452. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span><span class="o">.</span><span class="n">shape</span>
  453. <span class="go">(200, 200)</span>
  454. </pre></div>
  455. </div>
  456. </dd></dl>
  457. </div>
  458. <div class="section" id="module-ipfml.processing">
  459. <span id="ipfml-processing"></span><h2>ipfml.processing<a class="headerlink" href="#module-ipfml.processing" title="Permalink to this headline">¶</a></h2>
  460. <dl class="function">
  461. <dt id="ipfml.processing.divide_in_blocks">
  462. <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="headerlink" href="#ipfml.processing.divide_in_blocks" title="Permalink to this definition">¶</a></dt>
  463. <dd><p>Divide image into equal size blocks</p>
  464. <table class="docutils field-list" frame="void" rules="none">
  465. <col class="field-name" />
  466. <col class="field-body" />
  467. <tbody valign="top">
  468. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  469. <li><strong>image</strong> – PIL Image or Numpy array</li>
  470. <li><strong>block</strong> – tuple (width, height) representing the size of each dimension of the block</li>
  471. <li><strong>pil</strong> – block type returned (default True)</li>
  472. </ul>
  473. </td>
  474. </tr>
  475. <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>
  476. </td>
  477. </tr>
  478. <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_heigt</cite> are not compatible to produce correct block sizes</p>
  479. </td>
  480. </tr>
  481. </tbody>
  482. </table>
  483. <p>Example:</p>
  484. <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>
  485. <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>
  486. <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>
  487. <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>
  488. <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>
  489. <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>
  490. <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>
  491. <span class="go">1600</span>
  492. <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>
  493. <span class="go">20</span>
  494. <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>
  495. <span class="go">20</span>
  496. <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>
  497. <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>
  498. <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>
  499. <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>
  500. <span class="go">4</span>
  501. <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>
  502. <span class="go">100</span>
  503. </pre></div>
  504. </div>
  505. </dd></dl>
  506. <dl class="function">
  507. <dt id="ipfml.processing.get_LAB_L_SVD">
  508. <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="headerlink" href="#ipfml.processing.get_LAB_L_SVD" title="Permalink to this definition">¶</a></dt>
  509. <dd><p>Returns Singular values from LAB L Image information</p>
  510. <table class="docutils field-list" frame="void" rules="none">
  511. <col class="field-name" />
  512. <col class="field-body" />
  513. <tbody valign="top">
  514. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  515. </tr>
  516. <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>
  517. </tr>
  518. </tbody>
  519. </table>
  520. <p>Example:</p>
  521. <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>
  522. <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>
  523. <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>
  524. <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>
  525. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  526. <span class="go">(200, 200)</span>
  527. <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>
  528. <span class="go">200</span>
  529. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  530. <span class="go">(200, 200)</span>
  531. </pre></div>
  532. </div>
  533. </dd></dl>
  534. <dl class="function">
  535. <dt id="ipfml.processing.get_LAB_L_SVD_U">
  536. <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="headerlink" href="#ipfml.processing.get_LAB_L_SVD_U" title="Permalink to this definition">¶</a></dt>
  537. <dd><p>Returns U SVD from L of LAB Image information</p>
  538. <table class="docutils field-list" frame="void" rules="none">
  539. <col class="field-name" />
  540. <col class="field-body" />
  541. <tbody valign="top">
  542. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  543. </tr>
  544. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U matrix of SVD compression</td>
  545. </tr>
  546. </tbody>
  547. </table>
  548. <p>Example:</p>
  549. <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>
  550. <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>
  551. <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>
  552. <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>
  553. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  554. <span class="go">(200, 200)</span>
  555. </pre></div>
  556. </div>
  557. </dd></dl>
  558. <dl class="function">
  559. <dt id="ipfml.processing.get_LAB_L_SVD_V">
  560. <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="headerlink" href="#ipfml.processing.get_LAB_L_SVD_V" title="Permalink to this definition">¶</a></dt>
  561. <dd><p>Returns V SVD from L of LAB Image information</p>
  562. <table class="docutils field-list" frame="void" rules="none">
  563. <col class="field-name" />
  564. <col class="field-body" />
  565. <tbody valign="top">
  566. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  567. </tr>
  568. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">V matrix of SVD compression</td>
  569. </tr>
  570. </tbody>
  571. </table>
  572. <p>Example:</p>
  573. <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>
  574. <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>
  575. <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>
  576. <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>
  577. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  578. <span class="go">(200, 200)</span>
  579. </pre></div>
  580. </div>
  581. </dd></dl>
  582. <dl class="function">
  583. <dt id="ipfml.processing.get_LAB_L_SVD_s">
  584. <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="headerlink" href="#ipfml.processing.get_LAB_L_SVD_s" title="Permalink to this definition">¶</a></dt>
  585. <dd><p>Returns s (Singular values) SVD from L of LAB Image information</p>
  586. <table class="docutils field-list" frame="void" rules="none">
  587. <col class="field-name" />
  588. <col class="field-body" />
  589. <tbody valign="top">
  590. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  591. </tr>
  592. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">vector of singular values</td>
  593. </tr>
  594. </tbody>
  595. </table>
  596. <p>Example:</p>
  597. <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>
  598. <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>
  599. <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>
  600. <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>
  601. <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>
  602. <span class="go">200</span>
  603. </pre></div>
  604. </div>
  605. </dd></dl>
  606. <dl class="function">
  607. <dt id="ipfml.processing.normalize_2D_arr">
  608. <code class="descclassname">ipfml.processing.</code><code class="descname">normalize_2D_arr</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.processing.normalize_2D_arr" title="Permalink to this definition">¶</a></dt>
  609. <dd><p>Return array normalize from its min and max values</p>
  610. <table class="docutils field-list" frame="void" rules="none">
  611. <col class="field-name" />
  612. <col class="field-body" />
  613. <tbody valign="top">
  614. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – 2D Numpy array</td>
  615. </tr>
  616. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 2D Numpy array</td>
  617. </tr>
  618. </tbody>
  619. </table>
  620. <p>Example:</p>
  621. <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>
  622. <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>
  623. <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>
  624. <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>
  625. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">normalize_2D_arr</span><span class="p">(</span><span class="n">img_mscn</span><span class="p">)</span>
  626. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span><span class="o">.</span><span class="n">shape</span>
  627. <span class="go">(200, 200)</span>
  628. </pre></div>
  629. </div>
  630. </dd></dl>
  631. <dl class="function">
  632. <dt id="ipfml.processing.normalize_arr">
  633. <code class="descclassname">ipfml.processing.</code><code class="descname">normalize_arr</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.processing.normalize_arr" title="Permalink to this definition">¶</a></dt>
  634. <dd><p>Normalize data of 1D array shape</p>
  635. <table class="docutils field-list" frame="void" rules="none">
  636. <col class="field-name" />
  637. <col class="field-body" />
  638. <tbody valign="top">
  639. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  640. </tr>
  641. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D array</td>
  642. </tr>
  643. </tbody>
  644. </table>
  645. <p>Example:</p>
  646. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">processing</span>
  647. <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>
  648. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span>
  649. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">normalize_arr</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
  650. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  651. <span class="go">0.1</span>
  652. </pre></div>
  653. </div>
  654. </dd></dl>
  655. <dl class="function">
  656. <dt id="ipfml.processing.normalize_arr_with_range">
  657. <code class="descclassname">ipfml.processing.</code><code class="descname">normalize_arr_with_range</code><span class="sig-paren">(</span><em>arr</em>, <em>min</em>, <em>max</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.processing.normalize_arr_with_range" title="Permalink to this definition">¶</a></dt>
  658. <dd><p>Normalize data of 1D array shape</p>
  659. <table class="docutils field-list" frame="void" rules="none">
  660. <col class="field-name" />
  661. <col class="field-body" />
  662. <tbody valign="top">
  663. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  664. </tr>
  665. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D Numpy array</td>
  666. </tr>
  667. </tbody>
  668. </table>
  669. <p>Example:</p>
  670. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">processing</span>
  671. <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>
  672. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span>
  673. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">normalize_arr_with_range</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
  674. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  675. <span class="go">0.05</span>
  676. </pre></div>
  677. </div>
  678. </dd></dl>
  679. <dl class="function">
  680. <dt id="ipfml.processing.rgb_to_LAB_L_bits">
  681. <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="headerlink" href="#ipfml.processing.rgb_to_LAB_L_bits" title="Permalink to this definition">¶</a></dt>
  682. <dd><p>Returns only bits from LAB L canal specified into the interval</p>
  683. <table class="docutils field-list" frame="void" rules="none">
  684. <col class="field-name" />
  685. <col class="field-body" />
  686. <tbody valign="top">
  687. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  688. <li><strong>image</strong> – image to convert using this interval of bits value to keep</li>
  689. <li><strong>interval</strong> – (begin, end) of bits values</li>
  690. </ul>
  691. </td>
  692. </tr>
  693. <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>
  694. </td>
  695. </tr>
  696. </tbody>
  697. </table>
  698. <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>
  699. <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>
  700. <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>
  701. <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>
  702. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_Lab_l_img</span><span class="o">.</span><span class="n">shape</span>
  703. <span class="go">(200, 200)</span>
  704. </pre></div>
  705. </div>
  706. </dd></dl>
  707. <dl class="function">
  708. <dt id="ipfml.processing.rgb_to_LAB_L_low_bits">
  709. <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="headerlink" href="#ipfml.processing.rgb_to_LAB_L_low_bits" title="Permalink to this definition">¶</a></dt>
  710. <dd><p>Convert RGB Image into Lab L channel image using only 4 low bits values</p>
  711. <table class="docutils field-list" frame="void" rules="none">
  712. <col class="field-name" />
  713. <col class="field-body" />
  714. <tbody valign="top">
  715. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  716. <li><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</li>
  717. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep (default 4)</li>
  718. </ul>
  719. </td>
  720. </tr>
  721. <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>
  722. </td>
  723. </tr>
  724. </tbody>
  725. </table>
  726. <p>Example:</p>
  727. <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>
  728. <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>
  729. <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>
  730. <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>
  731. <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>
  732. <span class="go">(200, 200)</span>
  733. </pre></div>
  734. </div>
  735. </dd></dl>
  736. <dl class="function">
  737. <dt id="ipfml.processing.rgb_to_grey_low_bits">
  738. <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="headerlink" href="#ipfml.processing.rgb_to_grey_low_bits" title="Permalink to this definition">¶</a></dt>
  739. <dd><p>Convert RGB Image into grey image using only 4 low bits values</p>
  740. <table class="docutils field-list" frame="void" rules="none">
  741. <col class="field-name" />
  742. <col class="field-body" />
  743. <tbody valign="top">
  744. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  745. <li><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</li>
  746. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep (default 4)</li>
  747. </ul>
  748. </td>
  749. </tr>
  750. <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>
  751. </td>
  752. </tr>
  753. </tbody>
  754. </table>
  755. <p>Example:</p>
  756. <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>
  757. <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>
  758. <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>
  759. <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>
  760. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_grey_img</span><span class="o">.</span><span class="n">shape</span>
  761. <span class="go">(200, 200)</span>
  762. </pre></div>
  763. </div>
  764. </dd></dl>
  765. <dl class="function">
  766. <dt id="ipfml.processing.rgb_to_mscn">
  767. <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="headerlink" href="#ipfml.processing.rgb_to_mscn" title="Permalink to this definition">¶</a></dt>
  768. <dd><p>Convert RGB Image into Mean Subtracted Contrast Normalized (MSCN)</p>
  769. <table class="docutils field-list" frame="void" rules="none">
  770. <col class="field-name" />
  771. <col class="field-body" />
  772. <tbody valign="top">
  773. <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>
  774. </tr>
  775. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">2D Numpy array with MSCN information</td>
  776. </tr>
  777. </tbody>
  778. </table>
  779. <p>Example:</p>
  780. <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>
  781. <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>
  782. <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>
  783. <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>
  784. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span><span class="o">.</span><span class="n">shape</span>
  785. <span class="go">(200, 200)</span>
  786. </pre></div>
  787. </div>
  788. </dd></dl>
  789. </div>
  790. <div class="section" id="ipfml-filters">
  791. <h2>ipfml.filters<a class="headerlink" href="#ipfml-filters" title="Permalink to this headline">¶</a></h2>
  792. <div class="section" id="module-ipfml.filters.noise">
  793. <span id="ipfml-filters-noise"></span><h3>ipfml.filters.noise<a class="headerlink" href="#module-ipfml.filters.noise" title="Permalink to this headline">¶</a></h3>
  794. <dl class="function">
  795. <dt id="ipfml.filters.noise.cauchy_noise">
  796. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">cauchy_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>distribution_interval=(0</em>, <em>1)</em>, <em>k=0.0002</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.cauchy_noise" title="Permalink to this definition">¶</a></dt>
  797. <dd><p>Cauchy noise filter to apply on image</p>
  798. <table class="docutils field-list" frame="void" rules="none">
  799. <col class="field-name" />
  800. <col class="field-body" />
  801. <tbody valign="top">
  802. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  803. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  804. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  805. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  806. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  807. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.0002)</li>
  808. </ul>
  809. </td>
  810. </tr>
  811. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with Cauchy noise applied</p>
  812. </td>
  813. </tr>
  814. </tbody>
  815. </table>
  816. <p>Example:</p>
  817. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml.filters.noise</span> <span class="k">import</span> <span class="n">cauchy_noise</span>
  818. <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>
  819. <span class="gp">&gt;&gt;&gt; </span><span class="n">image</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  820. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">cauchy_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  821. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  822. <span class="go">(100, 100)</span>
  823. </pre></div>
  824. </div>
  825. </dd></dl>
  826. <dl class="function">
  827. <dt id="ipfml.filters.noise.gaussian_noise">
  828. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">gaussian_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>distribution_interval=(0</em>, <em>1)</em>, <em>k=0.1</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.gaussian_noise" title="Permalink to this definition">¶</a></dt>
  829. <dd><p>Gaussian noise filter to apply on image</p>
  830. <table class="docutils field-list" frame="void" rules="none">
  831. <col class="field-name" />
  832. <col class="field-body" />
  833. <tbody valign="top">
  834. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  835. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  836. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  837. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  838. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  839. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.1)</li>
  840. </ul>
  841. </td>
  842. </tr>
  843. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with gaussian noise applied</p>
  844. </td>
  845. </tr>
  846. </tbody>
  847. </table>
  848. <p>Example:</p>
  849. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml.filters.noise</span> <span class="k">import</span> <span class="n">gaussian_noise</span>
  850. <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>
  851. <span class="gp">&gt;&gt;&gt; </span><span class="n">image</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  852. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">gaussian_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  853. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  854. <span class="go">(100, 100)</span>
  855. </pre></div>
  856. </div>
  857. </dd></dl>
  858. <dl class="function">
  859. <dt id="ipfml.filters.noise.laplace_noise">
  860. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">laplace_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>distribution_interval=(0</em>, <em>1)</em>, <em>k=0.1</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.laplace_noise" title="Permalink to this definition">¶</a></dt>
  861. <dd><p>Laplace noise filter to apply on image</p>
  862. <table class="docutils field-list" frame="void" rules="none">
  863. <col class="field-name" />
  864. <col class="field-body" />
  865. <tbody valign="top">
  866. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  867. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  868. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  869. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  870. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  871. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.1)</li>
  872. </ul>
  873. </td>
  874. </tr>
  875. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpay array with Laplace noise applied</p>
  876. </td>
  877. </tr>
  878. </tbody>
  879. </table>
  880. <p>Example:</p>
  881. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml.filters.noise</span> <span class="k">import</span> <span class="n">laplace_noise</span>
  882. <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>
  883. <span class="gp">&gt;&gt;&gt; </span><span class="n">image</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  884. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">laplace_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  885. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  886. <span class="go">(100, 100)</span>
  887. </pre></div>
  888. </div>
  889. </dd></dl>
  890. <dl class="function">
  891. <dt id="ipfml.filters.noise.log_normal_noise">
  892. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">log_normal_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>distribution_interval=(0</em>, <em>1)</em>, <em>k=0.05</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.log_normal_noise" title="Permalink to this definition">¶</a></dt>
  893. <dd><p>Log-normal noise filter to apply on image</p>
  894. <table class="docutils field-list" frame="void" rules="none">
  895. <col class="field-name" />
  896. <col class="field-body" />
  897. <tbody valign="top">
  898. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  899. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  900. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  901. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  902. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  903. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.05)</li>
  904. </ul>
  905. </td>
  906. </tr>
  907. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with Log-normal noise applied</p>
  908. </td>
  909. </tr>
  910. </tbody>
  911. </table>
  912. <p>Example:</p>
  913. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml.filters.noise</span> <span class="k">import</span> <span class="n">log_normal_noise</span>
  914. <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>
  915. <span class="gp">&gt;&gt;&gt; </span><span class="n">image</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  916. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">log_normal_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  917. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  918. <span class="go">(100, 100)</span>
  919. </pre></div>
  920. </div>
  921. </dd></dl>
  922. <dl class="function">
  923. <dt id="ipfml.filters.noise.mut_white_noise">
  924. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">mut_white_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>distribution_interval=(-0.5</em>, <em>0.5)</em>, <em>k=0.2</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.mut_white_noise" title="Permalink to this definition">¶</a></dt>
  925. <dd><p>Multiplied White noise filter to apply on image</p>
  926. <table class="docutils field-list" frame="void" rules="none">
  927. <col class="field-name" />
  928. <col class="field-body" />
  929. <tbody valign="top">
  930. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  931. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  932. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  933. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  934. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (-0.5, 0.5))</li>
  935. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.2)</li>
  936. </ul>
  937. </td>
  938. </tr>
  939. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with multiplied white noise applied</p>
  940. </td>
  941. </tr>
  942. </tbody>
  943. </table>
  944. <p>Example:</p>
  945. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml.filters.noise</span> <span class="k">import</span> <span class="n">mut_white_noise</span>
  946. <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>
  947. <span class="gp">&gt;&gt;&gt; </span><span class="n">image</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  948. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">mut_white_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  949. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  950. <span class="go">(100, 100)</span>
  951. </pre></div>
  952. </div>
  953. </dd></dl>
  954. <dl class="function">
  955. <dt id="ipfml.filters.noise.white_noise">
  956. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">white_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>distribution_interval=(-0.5</em>, <em>0.5)</em>, <em>k=0.2</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.white_noise" title="Permalink to this definition">¶</a></dt>
  957. <dd><p>White noise filter to apply on image</p>
  958. <table class="docutils field-list" frame="void" rules="none">
  959. <col class="field-name" />
  960. <col class="field-body" />
  961. <tbody valign="top">
  962. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  963. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  964. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  965. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  966. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (-0.5, 0.5))</li>
  967. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.2)</li>
  968. </ul>
  969. </td>
  970. </tr>
  971. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with white noise applied</p>
  972. </td>
  973. </tr>
  974. </tbody>
  975. </table>
  976. <p>Example:</p>
  977. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml.filters.noise</span> <span class="k">import</span> <span class="n">white_noise</span>
  978. <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>
  979. <span class="gp">&gt;&gt;&gt; </span><span class="n">image</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
  980. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">white_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  981. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  982. <span class="go">(100, 100)</span>
  983. </pre></div>
  984. </div>
  985. </dd></dl>
  986. </div>
  987. </div>
  988. </div>
  989. </div>
  990. </div>
  991. <footer>
  992. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  993. <a href="examples.html" class="btn btn-neutral float-right" title="Examples" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
  994. <a href="description.html" class="btn btn-neutral" title="Description" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  995. </div>
  996. <hr/>
  997. <div role="contentinfo">
  998. <p>
  999. &copy; Copyright 2019, Jérôme BUISINE
  1000. </p>
  1001. </div>
  1002. 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>.
  1003. </footer>
  1004. </div>
  1005. </div>
  1006. </section>
  1007. </div>
  1008. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  1009. <script type="text/javascript" src="_static/jquery.js"></script>
  1010. <script type="text/javascript" src="_static/underscore.js"></script>
  1011. <script type="text/javascript" src="_static/doctools.js"></script>
  1012. <script type="text/javascript" src="_static/language_data.js"></script>
  1013. <script type="text/javascript" src="_static/js/theme.js"></script>
  1014. <script type="text/javascript">
  1015. jQuery(function () {
  1016. SphinxRtdTheme.Navigation.enable(true);
  1017. });
  1018. </script>
  1019. </body>
  1020. </html>