ipfml.html 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386
  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.6 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.6
  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. <li class="toctree-l2"><a class="reference internal" href="#ipfml-iqa">ipfml.iqa</a><ul>
  46. <li class="toctree-l3"><a class="reference internal" href="#module-ipfml.iqa.fr">ipfml.iqa.fr</a></li>
  47. </ul>
  48. </li>
  49. <li class="toctree-l2"><a class="reference internal" href="#module-ipfml.utils">ipfml.utils</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="#module-ipfml.exceptions">ipfml.exceptions</a></li>
  51. </ul>
  52. </li>
  53. <li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
  54. <li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
  55. </ul>
  56. </div>
  57. </div>
  58. </nav>
  59. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  60. <nav class="wy-nav-top" aria-label="top navigation">
  61. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  62. <a href="index.html">IPFML</a>
  63. </nav>
  64. <div class="wy-nav-content">
  65. <div class="rst-content">
  66. <div role="navigation" aria-label="breadcrumbs navigation">
  67. <ul class="wy-breadcrumbs">
  68. <li><a href="index.html">Docs</a> &raquo;</li>
  69. <li>Documentation</li>
  70. <li class="wy-breadcrumbs-aside">
  71. <a href="https://github.com/jbuisine/IPFML/blob/master/docs/source/ipfml.rst" class="fa fa-github"> Edit on GitHub</a>
  72. </li>
  73. </ul>
  74. <hr/>
  75. </div>
  76. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  77. <div itemprop="articleBody">
  78. <div class="section" id="documentation">
  79. <h1>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h1>
  80. <div class="section" id="module-ipfml.metrics">
  81. <span id="ipfml-metrics"></span><h2>ipfml.metrics<a class="headerlink" href="#module-ipfml.metrics" title="Permalink to this headline">¶</a></h2>
  82. <dl class="function">
  83. <dt id="ipfml.metrics.get_LAB">
  84. <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>
  85. <dd><p>Transforms RGB Image into Lab</p>
  86. <table class="docutils field-list" frame="void" rules="none">
  87. <col class="field-name" />
  88. <col class="field-body" />
  89. <tbody valign="top">
  90. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  91. </tr>
  92. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Lab information</td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <p>Usage:</p>
  97. <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>
  98. <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>
  99. <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>
  100. <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>
  101. <span class="gp">&gt;&gt;&gt; </span><span class="n">Lab</span><span class="o">.</span><span class="n">shape</span>
  102. <span class="go">(200, 200, 3)</span>
  103. </pre></div>
  104. </div>
  105. </dd></dl>
  106. <dl class="function">
  107. <dt id="ipfml.metrics.get_LAB_L">
  108. <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>
  109. <dd><p>Transforms RGB Image into Lab and returns L</p>
  110. <table class="docutils field-list" frame="void" rules="none">
  111. <col class="field-name" />
  112. <col class="field-body" />
  113. <tbody valign="top">
  114. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  115. </tr>
  116. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The L chanel from Lab information</td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. <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>
  121. <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>
  122. <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>
  123. <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>
  124. <span class="gp">&gt;&gt;&gt; </span><span class="n">L</span><span class="o">.</span><span class="n">shape</span>
  125. <span class="go">(200, 200)</span>
  126. </pre></div>
  127. </div>
  128. </dd></dl>
  129. <dl class="function">
  130. <dt id="ipfml.metrics.get_LAB_a">
  131. <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>
  132. <dd><p>Transforms RGB Image into LAB and returns a</p>
  133. <table class="docutils field-list" frame="void" rules="none">
  134. <col class="field-name" />
  135. <col class="field-body" />
  136. <tbody valign="top">
  137. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  138. </tr>
  139. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The a chanel from Lab information</td>
  140. </tr>
  141. </tbody>
  142. </table>
  143. <p>Usage:</p>
  144. <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>
  145. <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>
  146. <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>
  147. <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>
  148. <span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">shape</span>
  149. <span class="go">(200, 200)</span>
  150. </pre></div>
  151. </div>
  152. </dd></dl>
  153. <dl class="function">
  154. <dt id="ipfml.metrics.get_LAB_b">
  155. <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>
  156. <dd><p>Transforms RGB Image into LAB and returns b</p>
  157. <table class="docutils field-list" frame="void" rules="none">
  158. <col class="field-name" />
  159. <col class="field-body" />
  160. <tbody valign="top">
  161. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  162. </tr>
  163. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The b chanel from Lab information</td>
  164. </tr>
  165. </tbody>
  166. </table>
  167. <p>Usage :</p>
  168. <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>
  169. <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>
  170. <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>
  171. <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>
  172. <span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">shape</span>
  173. <span class="go">(200, 200)</span>
  174. </pre></div>
  175. </div>
  176. </dd></dl>
  177. <dl class="function">
  178. <dt id="ipfml.metrics.get_SVD">
  179. <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>
  180. <dd><p>Transforms Image using SVD compression</p>
  181. <table class="docutils field-list" frame="void" rules="none">
  182. <col class="field-name" />
  183. <col class="field-body" />
  184. <tbody valign="top">
  185. <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>
  186. </tr>
  187. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U, s, V obtained from SVD compression</td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <p>Usage:</p>
  192. <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>
  193. <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>
  194. <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>
  195. <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>
  196. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  197. <span class="go">(200, 200, 3)</span>
  198. <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>
  199. <span class="go">200</span>
  200. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  201. <span class="go">(200, 3, 3)</span>
  202. </pre></div>
  203. </div>
  204. </dd></dl>
  205. <dl class="function">
  206. <dt id="ipfml.metrics.get_SVD_U">
  207. <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>
  208. <dd><p>Transforms Image into SVD and returns only ‘U’ part</p>
  209. <table class="docutils field-list" frame="void" rules="none">
  210. <col class="field-name" />
  211. <col class="field-body" />
  212. <tbody valign="top">
  213. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  214. </tr>
  215. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U matrix from SVD compression</td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. <p>Usage:</p>
  220. <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>
  221. <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>
  222. <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>
  223. <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>
  224. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  225. <span class="go">(200, 200, 3)</span>
  226. </pre></div>
  227. </div>
  228. </dd></dl>
  229. <dl class="function">
  230. <dt id="ipfml.metrics.get_SVD_V">
  231. <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>
  232. <dd><p>Transforms Image into SVD and returns only ‘V’ part</p>
  233. <table class="docutils field-list" frame="void" rules="none">
  234. <col class="field-name" />
  235. <col class="field-body" />
  236. <tbody valign="top">
  237. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  238. </tr>
  239. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">V matrix obtained from SVD compression</td>
  240. </tr>
  241. </tbody>
  242. </table>
  243. <p>Usage :</p>
  244. <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>
  245. <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>
  246. <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>
  247. <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>
  248. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  249. <span class="go">(200, 3, 3)</span>
  250. </pre></div>
  251. </div>
  252. </dd></dl>
  253. <dl class="function">
  254. <dt id="ipfml.metrics.get_SVD_s">
  255. <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>
  256. <dd><p>Transforms Image into SVD and returns only ‘s’ part</p>
  257. <table class="docutils field-list" frame="void" rules="none">
  258. <col class="field-name" />
  259. <col class="field-body" />
  260. <tbody valign="top">
  261. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  262. </tr>
  263. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">vector of singular values obtained from SVD compression</td>
  264. </tr>
  265. </tbody>
  266. </table>
  267. <p>Usage:</p>
  268. <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>
  269. <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>
  270. <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>
  271. <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>
  272. <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>
  273. <span class="go">200</span>
  274. </pre></div>
  275. </div>
  276. </dd></dl>
  277. <dl class="function">
  278. <dt id="ipfml.metrics.get_XYZ">
  279. <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>
  280. <dd><p>Transforms RGB Image into XYZ</p>
  281. <table class="docutils field-list" frame="void" rules="none">
  282. <col class="field-name" />
  283. <col class="field-body" />
  284. <tbody valign="top">
  285. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  286. </tr>
  287. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">XYZ information obtained from transformation</td>
  288. </tr>
  289. </tbody>
  290. </table>
  291. <p>Usage:</p>
  292. <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>
  293. <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>
  294. <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>
  295. <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>
  296. <span class="go">(200, 200, 3)</span>
  297. </pre></div>
  298. </div>
  299. </dd></dl>
  300. <dl class="function">
  301. <dt id="ipfml.metrics.get_XYZ_X">
  302. <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>
  303. <dd><p>Transforms RGB Image into XYZ and returns X</p>
  304. <table class="docutils field-list" frame="void" rules="none">
  305. <col class="field-name" />
  306. <col class="field-body" />
  307. <tbody valign="top">
  308. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  309. </tr>
  310. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The X chanel from XYZ information</td>
  311. </tr>
  312. </tbody>
  313. </table>
  314. <p>Usage:</p>
  315. <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>
  316. <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>
  317. <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>
  318. <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>
  319. <span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">.</span><span class="n">shape</span>
  320. <span class="go">(200, 200)</span>
  321. </pre></div>
  322. </div>
  323. </dd></dl>
  324. <dl class="function">
  325. <dt id="ipfml.metrics.get_XYZ_Y">
  326. <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>
  327. <dd><p>Transforms RGB Image into XYZ and returns Y</p>
  328. <table class="docutils field-list" frame="void" rules="none">
  329. <col class="field-name" />
  330. <col class="field-body" />
  331. <tbody valign="top">
  332. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  333. </tr>
  334. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The Y chanel from XYZ information</td>
  335. </tr>
  336. </tbody>
  337. </table>
  338. <p>Usage:</p>
  339. <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>
  340. <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>
  341. <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>
  342. <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>
  343. <span class="gp">&gt;&gt;&gt; </span><span class="n">y</span><span class="o">.</span><span class="n">shape</span>
  344. <span class="go">(200, 200)</span>
  345. </pre></div>
  346. </div>
  347. </dd></dl>
  348. <dl class="function">
  349. <dt id="ipfml.metrics.get_XYZ_Z">
  350. <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>
  351. <dd><p>Transforms RGB Image into XYZ and returns Z</p>
  352. <table class="docutils field-list" frame="void" rules="none">
  353. <col class="field-name" />
  354. <col class="field-body" />
  355. <tbody valign="top">
  356. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – image to convert</td>
  357. </tr>
  358. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The Z chanel from XYZ information</td>
  359. </tr>
  360. <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>
  361. </tr>
  362. </tbody>
  363. </table>
  364. <p>Usage:</p>
  365. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
  366. <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">metrics</span>
  367. <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>
  368. <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>
  369. <span class="gp">&gt;&gt;&gt; </span><span class="n">z</span><span class="o">.</span><span class="n">shape</span>
  370. <span class="go">(200, 200)</span>
  371. </pre></div>
  372. </div>
  373. </dd></dl>
  374. <dl class="function">
  375. <dt id="ipfml.metrics.get_bits_img">
  376. <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>
  377. <dd><p>Returns only bits specified into the interval</p>
  378. <table class="docutils field-list" frame="void" rules="none">
  379. <col class="field-name" />
  380. <col class="field-body" />
  381. <tbody valign="top">
  382. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  383. <li><strong>image</strong> – image to convert using this interval of bits value to keep</li>
  384. <li><strong>interval</strong> – (begin, end) of bits values</li>
  385. </ul>
  386. </td>
  387. </tr>
  388. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Numpy array with reduced values</p>
  389. </td>
  390. </tr>
  391. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  392. <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>
  393. <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>
  394. <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>
  395. </ul>
  396. </td>
  397. </tr>
  398. </tbody>
  399. </table>
  400. <p>Usage:</p>
  401. <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>
  402. <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>
  403. <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>
  404. <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>
  405. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_img</span><span class="o">.</span><span class="n">shape</span>
  406. <span class="go">(200, 200, 3)</span>
  407. </pre></div>
  408. </div>
  409. </dd></dl>
  410. <dl class="function">
  411. <dt id="ipfml.metrics.get_low_bits_img">
  412. <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>
  413. <dd><p>Returns Image or Numpy array with data information reduced using only low bits</p>
  414. <table class="docutils field-list" frame="void" rules="none">
  415. <col class="field-name" />
  416. <col class="field-body" />
  417. <tbody valign="top">
  418. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  419. <li><strong>image</strong> – image to convert</li>
  420. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep</li>
  421. </ul>
  422. </td>
  423. </tr>
  424. <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>
  425. </td>
  426. </tr>
  427. </tbody>
  428. </table>
  429. <p>Usage:</p>
  430. <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>
  431. <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>
  432. <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>
  433. <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>
  434. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_img</span><span class="o">.</span><span class="n">shape</span>
  435. <span class="go">(200, 200, 3)</span>
  436. </pre></div>
  437. </div>
  438. </dd></dl>
  439. <dl class="function">
  440. <dt id="ipfml.metrics.gray_to_mscn">
  441. <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>
  442. <dd><p>Convert Grayscale Image into Mean Subtracted Contrast Normalized (MSCN)</p>
  443. <table class="docutils field-list" frame="void" rules="none">
  444. <col class="field-name" />
  445. <col class="field-body" />
  446. <tbody valign="top">
  447. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – grayscale image</td>
  448. </tr>
  449. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">MSCN matrix obtained from transformation</td>
  450. </tr>
  451. </tbody>
  452. </table>
  453. <p>Usage:</p>
  454. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
  455. <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">processing</span>
  456. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;./images/test_img.png&#39;</span><span class="p">)</span>
  457. <span class="gp">&gt;&gt;&gt; </span><span class="n">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>
  458. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span><span class="o">.</span><span class="n">shape</span>
  459. <span class="go">(200, 200)</span>
  460. </pre></div>
  461. </div>
  462. </dd></dl>
  463. </div>
  464. <div class="section" id="module-ipfml.processing">
  465. <span id="ipfml-processing"></span><h2>ipfml.processing<a class="headerlink" href="#module-ipfml.processing" title="Permalink to this headline">¶</a></h2>
  466. <dl class="function">
  467. <dt id="ipfml.processing.divide_in_blocks">
  468. <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>
  469. <dd><p>Divide image into equal size blocks</p>
  470. <table class="docutils field-list" frame="void" rules="none">
  471. <col class="field-name" />
  472. <col class="field-body" />
  473. <tbody valign="top">
  474. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  475. <li><strong>image</strong> – PIL Image or Numpy array</li>
  476. <li><strong>block</strong> – tuple (width, height) representing the size of each dimension of the block</li>
  477. <li><strong>pil</strong> – block type returned (default True)</li>
  478. </ul>
  479. </td>
  480. </tr>
  481. <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>
  482. </td>
  483. </tr>
  484. <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>
  485. </td>
  486. </tr>
  487. </tbody>
  488. </table>
  489. <p>Example:</p>
  490. <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>
  491. <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>
  492. <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>
  493. <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>
  494. <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>
  495. <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>
  496. <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>
  497. <span class="go">1600</span>
  498. <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>
  499. <span class="go">20</span>
  500. <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>
  501. <span class="go">20</span>
  502. <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>
  503. <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>
  504. <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>
  505. <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>
  506. <span class="go">4</span>
  507. <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>
  508. <span class="go">100</span>
  509. </pre></div>
  510. </div>
  511. </dd></dl>
  512. <dl class="function">
  513. <dt id="ipfml.processing.get_LAB_L_SVD">
  514. <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>
  515. <dd><p>Returns Singular values from LAB L Image information</p>
  516. <table class="docutils field-list" frame="void" rules="none">
  517. <col class="field-name" />
  518. <col class="field-body" />
  519. <tbody valign="top">
  520. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  521. </tr>
  522. <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>
  523. </tr>
  524. </tbody>
  525. </table>
  526. <p>Example:</p>
  527. <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>
  528. <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>
  529. <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>
  530. <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>
  531. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  532. <span class="go">(200, 200)</span>
  533. <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>
  534. <span class="go">200</span>
  535. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  536. <span class="go">(200, 200)</span>
  537. </pre></div>
  538. </div>
  539. </dd></dl>
  540. <dl class="function">
  541. <dt id="ipfml.processing.get_LAB_L_SVD_U">
  542. <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>
  543. <dd><p>Returns U SVD from L of LAB Image information</p>
  544. <table class="docutils field-list" frame="void" rules="none">
  545. <col class="field-name" />
  546. <col class="field-body" />
  547. <tbody valign="top">
  548. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  549. </tr>
  550. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">U matrix of SVD compression</td>
  551. </tr>
  552. </tbody>
  553. </table>
  554. <p>Example:</p>
  555. <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>
  556. <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>
  557. <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>
  558. <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>
  559. <span class="gp">&gt;&gt;&gt; </span><span class="n">U</span><span class="o">.</span><span class="n">shape</span>
  560. <span class="go">(200, 200)</span>
  561. </pre></div>
  562. </div>
  563. </dd></dl>
  564. <dl class="function">
  565. <dt id="ipfml.processing.get_LAB_L_SVD_V">
  566. <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>
  567. <dd><p>Returns V SVD from L of LAB Image information</p>
  568. <table class="docutils field-list" frame="void" rules="none">
  569. <col class="field-name" />
  570. <col class="field-body" />
  571. <tbody valign="top">
  572. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  573. </tr>
  574. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">V matrix of SVD compression</td>
  575. </tr>
  576. </tbody>
  577. </table>
  578. <p>Example:</p>
  579. <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>
  580. <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>
  581. <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>
  582. <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>
  583. <span class="gp">&gt;&gt;&gt; </span><span class="n">V</span><span class="o">.</span><span class="n">shape</span>
  584. <span class="go">(200, 200)</span>
  585. </pre></div>
  586. </div>
  587. </dd></dl>
  588. <dl class="function">
  589. <dt id="ipfml.processing.get_LAB_L_SVD_s">
  590. <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>
  591. <dd><p>Returns s (Singular values) SVD from L of LAB Image information</p>
  592. <table class="docutils field-list" frame="void" rules="none">
  593. <col class="field-name" />
  594. <col class="field-body" />
  595. <tbody valign="top">
  596. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>image</strong> – PIL Image or Numpy array</td>
  597. </tr>
  598. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">vector of singular values</td>
  599. </tr>
  600. </tbody>
  601. </table>
  602. <p>Example:</p>
  603. <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>
  604. <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>
  605. <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>
  606. <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>
  607. <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>
  608. <span class="go">200</span>
  609. </pre></div>
  610. </div>
  611. </dd></dl>
  612. <dl class="function">
  613. <dt id="ipfml.processing.rgb_to_LAB_L_bits">
  614. <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>
  615. <dd><p>Returns only bits from LAB L canal specified into the interval</p>
  616. <table class="docutils field-list" frame="void" rules="none">
  617. <col class="field-name" />
  618. <col class="field-body" />
  619. <tbody valign="top">
  620. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  621. <li><strong>image</strong> – image to convert using this interval of bits value to keep</li>
  622. <li><strong>interval</strong> – (begin, end) of bits values</li>
  623. </ul>
  624. </td>
  625. </tr>
  626. <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>
  627. </td>
  628. </tr>
  629. </tbody>
  630. </table>
  631. <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>
  632. <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>
  633. <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>
  634. <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>
  635. <span class="gp">&gt;&gt;&gt; </span><span class="n">bits_Lab_l_img</span><span class="o">.</span><span class="n">shape</span>
  636. <span class="go">(200, 200)</span>
  637. </pre></div>
  638. </div>
  639. </dd></dl>
  640. <dl class="function">
  641. <dt id="ipfml.processing.rgb_to_LAB_L_low_bits">
  642. <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>
  643. <dd><p>Convert RGB Image into Lab L channel image using only 4 low bits values</p>
  644. <table class="docutils field-list" frame="void" rules="none">
  645. <col class="field-name" />
  646. <col class="field-body" />
  647. <tbody valign="top">
  648. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  649. <li><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</li>
  650. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep (default 4)</li>
  651. </ul>
  652. </td>
  653. </tr>
  654. <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>
  655. </td>
  656. </tr>
  657. </tbody>
  658. </table>
  659. <p>Example:</p>
  660. <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>
  661. <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>
  662. <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>
  663. <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>
  664. <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>
  665. <span class="go">(200, 200)</span>
  666. </pre></div>
  667. </div>
  668. </dd></dl>
  669. <dl class="function">
  670. <dt id="ipfml.processing.rgb_to_grey_low_bits">
  671. <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>
  672. <dd><p>Convert RGB Image into grey image using only 4 low bits values</p>
  673. <table class="docutils field-list" frame="void" rules="none">
  674. <col class="field-name" />
  675. <col class="field-body" />
  676. <tbody valign="top">
  677. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  678. <li><strong>image</strong> – 3D RGB image Numpy array or PIL RGB image</li>
  679. <li><strong>nb_bits</strong> – optional parameter which indicates the number of bits to keep (default 4)</li>
  680. </ul>
  681. </td>
  682. </tr>
  683. <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>
  684. </td>
  685. </tr>
  686. </tbody>
  687. </table>
  688. <p>Example:</p>
  689. <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>
  690. <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>
  691. <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>
  692. <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>
  693. <span class="gp">&gt;&gt;&gt; </span><span class="n">low_bits_grey_img</span><span class="o">.</span><span class="n">shape</span>
  694. <span class="go">(200, 200)</span>
  695. </pre></div>
  696. </div>
  697. </dd></dl>
  698. <dl class="function">
  699. <dt id="ipfml.processing.rgb_to_mscn">
  700. <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>
  701. <dd><p>Convert RGB Image into Mean Subtracted Contrast Normalized (MSCN)</p>
  702. <table class="docutils field-list" frame="void" rules="none">
  703. <col class="field-name" />
  704. <col class="field-body" />
  705. <tbody valign="top">
  706. <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>
  707. </tr>
  708. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">2D Numpy array with MSCN information</td>
  709. </tr>
  710. </tbody>
  711. </table>
  712. <p>Example:</p>
  713. <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>
  714. <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>
  715. <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>
  716. <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>
  717. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span><span class="o">.</span><span class="n">shape</span>
  718. <span class="go">(200, 200)</span>
  719. </pre></div>
  720. </div>
  721. </dd></dl>
  722. </div>
  723. <div class="section" id="ipfml-filters">
  724. <h2>ipfml.filters<a class="headerlink" href="#ipfml-filters" title="Permalink to this headline">¶</a></h2>
  725. <div class="section" id="module-ipfml.filters.noise">
  726. <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>
  727. <dl class="function">
  728. <dt id="ipfml.filters.noise.cauchy_noise">
  729. <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>
  730. <dd><p>Cauchy noise filter to apply on image</p>
  731. <table class="docutils field-list" frame="void" rules="none">
  732. <col class="field-name" />
  733. <col class="field-body" />
  734. <tbody valign="top">
  735. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  736. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  737. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  738. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  739. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  740. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.0002)</li>
  741. </ul>
  742. </td>
  743. </tr>
  744. <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>
  745. </td>
  746. </tr>
  747. </tbody>
  748. </table>
  749. <p>Example:</p>
  750. <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>
  751. <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>
  752. <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>
  753. <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>
  754. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  755. <span class="go">(100, 100)</span>
  756. </pre></div>
  757. </div>
  758. </dd></dl>
  759. <dl class="function">
  760. <dt id="ipfml.filters.noise.gaussian_noise">
  761. <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>
  762. <dd><p>Gaussian noise filter to apply on image</p>
  763. <table class="docutils field-list" frame="void" rules="none">
  764. <col class="field-name" />
  765. <col class="field-body" />
  766. <tbody valign="top">
  767. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  768. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  769. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  770. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  771. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  772. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.1)</li>
  773. </ul>
  774. </td>
  775. </tr>
  776. <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>
  777. </td>
  778. </tr>
  779. </tbody>
  780. </table>
  781. <p>Example:</p>
  782. <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>
  783. <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>
  784. <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>
  785. <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>
  786. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  787. <span class="go">(100, 100)</span>
  788. </pre></div>
  789. </div>
  790. </dd></dl>
  791. <dl class="function">
  792. <dt id="ipfml.filters.noise.laplace_noise">
  793. <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>
  794. <dd><p>Laplace noise filter to apply on image</p>
  795. <table class="docutils field-list" frame="void" rules="none">
  796. <col class="field-name" />
  797. <col class="field-body" />
  798. <tbody valign="top">
  799. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  800. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  801. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  802. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  803. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  804. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.1)</li>
  805. </ul>
  806. </td>
  807. </tr>
  808. <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>
  809. </td>
  810. </tr>
  811. </tbody>
  812. </table>
  813. <p>Example:</p>
  814. <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>
  815. <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>
  816. <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>
  817. <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>
  818. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  819. <span class="go">(100, 100)</span>
  820. </pre></div>
  821. </div>
  822. </dd></dl>
  823. <dl class="function">
  824. <dt id="ipfml.filters.noise.log_normal_noise">
  825. <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>
  826. <dd><p>Log-normal noise filter to apply on image</p>
  827. <table class="docutils field-list" frame="void" rules="none">
  828. <col class="field-name" />
  829. <col class="field-body" />
  830. <tbody valign="top">
  831. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  832. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  833. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  834. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  835. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  836. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.05)</li>
  837. </ul>
  838. </td>
  839. </tr>
  840. <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>
  841. </td>
  842. </tr>
  843. </tbody>
  844. </table>
  845. <p>Example:</p>
  846. <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>
  847. <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>
  848. <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>
  849. <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>
  850. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  851. <span class="go">(100, 100)</span>
  852. </pre></div>
  853. </div>
  854. </dd></dl>
  855. <dl class="function">
  856. <dt id="ipfml.filters.noise.mut_white_noise">
  857. <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</em>, <em>1)</em>, <em>k=0.002</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.mut_white_noise" title="Permalink to this definition">¶</a></dt>
  858. <dd><p>Multiplied White noise filter to apply on image</p>
  859. <table class="docutils field-list" frame="void" rules="none">
  860. <col class="field-name" />
  861. <col class="field-body" />
  862. <tbody valign="top">
  863. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  864. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  865. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  866. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  867. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (0, 1))</li>
  868. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.002)</li>
  869. </ul>
  870. </td>
  871. </tr>
  872. <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>
  873. </td>
  874. </tr>
  875. </tbody>
  876. </table>
  877. <p>Example:</p>
  878. <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>
  879. <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>
  880. <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>
  881. <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>
  882. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  883. <span class="go">(100, 100)</span>
  884. </pre></div>
  885. </div>
  886. </dd></dl>
  887. <dl class="function">
  888. <dt id="ipfml.filters.noise.salt_pepper_noise">
  889. <code class="descclassname">ipfml.filters.noise.</code><code class="descname">salt_pepper_noise</code><span class="sig-paren">(</span><em>image</em>, <em>n</em>, <em>identical=False</em>, <em>p=0.1</em>, <em>k=0.5</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.filters.noise.salt_pepper_noise" title="Permalink to this definition">¶</a></dt>
  890. <dd><p>Pepper salt noise filter to apply on image</p>
  891. <table class="docutils field-list" frame="void" rules="none">
  892. <col class="field-name" />
  893. <col class="field-body" />
  894. <tbody valign="top">
  895. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  896. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  897. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  898. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  899. <li><strong>p</strong> – probability to increase pixel value otherwise decrease it</li>
  900. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.5)</li>
  901. </ul>
  902. </td>
  903. </tr>
  904. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">2D Numpy array with salt and pepper noise applied</p>
  905. </td>
  906. </tr>
  907. </tbody>
  908. </table>
  909. <p>Example:</p>
  910. <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">salt_pepper_noise</span>
  911. <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>
  912. <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>
  913. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span> <span class="o">=</span> <span class="n">salt_pepper_noise</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
  914. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  915. <span class="go">(100, 100)</span>
  916. </pre></div>
  917. </div>
  918. </dd></dl>
  919. <dl class="function">
  920. <dt id="ipfml.filters.noise.white_noise">
  921. <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>
  922. <dd><p>White noise filter to apply on image</p>
  923. <table class="docutils field-list" frame="void" rules="none">
  924. <col class="field-name" />
  925. <col class="field-body" />
  926. <tbody valign="top">
  927. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  928. <li><strong>image</strong> – image used as input (2D or 3D image representation)</li>
  929. <li><strong>n</strong> – used to set importance of noise [1, 999]</li>
  930. <li><strong>identical</strong> – keep or not identical noise distribution for each canal if RGB Image (default False)</li>
  931. <li><strong>distribution_interval</strong> – set the distribution interval of normal law distribution (default (-0.5, 0.5))</li>
  932. <li><strong>k</strong> – variable that specifies the amount of noise to be taken into account in the output image (default 0.2)</li>
  933. </ul>
  934. </td>
  935. </tr>
  936. <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>
  937. </td>
  938. </tr>
  939. </tbody>
  940. </table>
  941. <p>Example:</p>
  942. <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>
  943. <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>
  944. <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>
  945. <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>
  946. <span class="gp">&gt;&gt;&gt; </span><span class="n">noisy_image</span><span class="o">.</span><span class="n">shape</span>
  947. <span class="go">(100, 100)</span>
  948. </pre></div>
  949. </div>
  950. </dd></dl>
  951. </div>
  952. </div>
  953. <div class="section" id="ipfml-iqa">
  954. <h2>ipfml.iqa<a class="headerlink" href="#ipfml-iqa" title="Permalink to this headline">¶</a></h2>
  955. <div class="section" id="module-ipfml.iqa.fr">
  956. <span id="ipfml-iqa-fr"></span><h3>ipfml.iqa.fr<a class="headerlink" href="#module-ipfml.iqa.fr" title="Permalink to this headline">¶</a></h3>
  957. <dl class="function">
  958. <dt id="ipfml.iqa.fr.mae">
  959. <code class="descclassname">ipfml.iqa.fr.</code><code class="descname">mae</code><span class="sig-paren">(</span><em>img_true</em>, <em>img_test</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.iqa.fr.mae" title="Permalink to this definition">¶</a></dt>
  960. <dd><p>Returns Mean Absolute Error between two Numpy arrays</p>
  961. <table class="docutils field-list" frame="void" rules="none">
  962. <col class="field-name" />
  963. <col class="field-body" />
  964. <tbody valign="top">
  965. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  966. <li><strong>img_true</strong> – Image, numpy array of any dimension</li>
  967. <li><strong>img_test</strong> – Image, numpy array of any dimension</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">Computed MAE score</p>
  972. </td>
  973. </tr>
  974. <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">NumpyShapeComparisonException</span></code> – if shape of images are not the same</p>
  975. </td>
  976. </tr>
  977. </tbody>
  978. </table>
  979. <p class="rubric">Example</p>
  980. <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.iqa</span> <span class="k">import</span> <span class="n">fr</span>
  981. <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>
  982. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  983. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr2</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">5</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
  984. <span class="gp">&gt;&gt;&gt; </span><span class="n">mae_score</span> <span class="o">=</span> <span class="n">fr</span><span class="o">.</span><span class="n">mae</span><span class="p">(</span><span class="n">arr1</span><span class="p">,</span> <span class="n">arr2</span><span class="p">)</span>
  985. <span class="gp">&gt;&gt;&gt; </span><span class="n">mae_score</span>
  986. <span class="go">5.0</span>
  987. </pre></div>
  988. </div>
  989. </dd></dl>
  990. <dl class="function">
  991. <dt id="ipfml.iqa.fr.ms_ssim">
  992. <code class="descclassname">ipfml.iqa.fr.</code><code class="descname">ms_ssim</code><span class="sig-paren">(</span><em>img_true</em>, <em>img_test</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.iqa.fr.ms_ssim" title="Permalink to this definition">¶</a></dt>
  993. <dd><p>Implemented later..</p>
  994. </dd></dl>
  995. <dl class="function">
  996. <dt id="ipfml.iqa.fr.mse">
  997. <code class="descclassname">ipfml.iqa.fr.</code><code class="descname">mse</code><span class="sig-paren">(</span><em>img_true</em>, <em>img_test</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.iqa.fr.mse" title="Permalink to this definition">¶</a></dt>
  998. <dd><p>Returns Mean-Squared Error score between two Numpy arrays</p>
  999. <table class="docutils field-list" frame="void" rules="none">
  1000. <col class="field-name" />
  1001. <col class="field-body" />
  1002. <tbody valign="top">
  1003. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1004. <li><strong>img_true</strong> – Image, numpy array of any dimension</li>
  1005. <li><strong>img_test</strong> – Image, numpy array of any dimension</li>
  1006. </ul>
  1007. </td>
  1008. </tr>
  1009. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Computed MSE score</p>
  1010. </td>
  1011. </tr>
  1012. <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">NumpyShapeComparisonException</span></code> – if shape of images are not the same</p>
  1013. </td>
  1014. </tr>
  1015. </tbody>
  1016. </table>
  1017. <p class="rubric">Example</p>
  1018. <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.iqa</span> <span class="k">import</span> <span class="n">fr</span>
  1019. <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>
  1020. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  1021. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr2</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">5</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
  1022. <span class="gp">&gt;&gt;&gt; </span><span class="n">mse_score</span> <span class="o">=</span> <span class="n">fr</span><span class="o">.</span><span class="n">mse</span><span class="p">(</span><span class="n">arr1</span><span class="p">,</span> <span class="n">arr2</span><span class="p">)</span>
  1023. <span class="gp">&gt;&gt;&gt; </span><span class="n">mse_score</span>
  1024. <span class="go">25.0</span>
  1025. </pre></div>
  1026. </div>
  1027. </dd></dl>
  1028. <dl class="function">
  1029. <dt id="ipfml.iqa.fr.pnsr">
  1030. <code class="descclassname">ipfml.iqa.fr.</code><code class="descname">pnsr</code><span class="sig-paren">(</span><em>img_true</em>, <em>img_test</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.iqa.fr.pnsr" title="Permalink to this definition">¶</a></dt>
  1031. <dd><p>Returns the computed Peak Signal to Noise Ratio (PSNR) between two images</p>
  1032. <table class="docutils field-list" frame="void" rules="none">
  1033. <col class="field-name" />
  1034. <col class="field-body" />
  1035. <tbody valign="top">
  1036. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1037. <li><strong>img_true</strong> – Image, numpy array of any dimension</li>
  1038. <li><strong>img_test</strong> – Image, numpy array of any dimension</li>
  1039. </ul>
  1040. </td>
  1041. </tr>
  1042. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Computed PSNR score</p>
  1043. </td>
  1044. </tr>
  1045. </tbody>
  1046. </table>
  1047. <p class="rubric">Example</p>
  1048. <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.iqa</span> <span class="k">import</span> <span class="n">fr</span>
  1049. <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>
  1050. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  1051. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr2</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">5</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
  1052. <span class="gp">&gt;&gt;&gt; </span><span class="n">pnsr_score</span> <span class="o">=</span> <span class="n">fr</span><span class="o">.</span><span class="n">pnsr</span><span class="p">(</span><span class="n">arr1</span><span class="p">,</span> <span class="n">arr2</span><span class="p">)</span>
  1053. <span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">pnsr_score</span><span class="p">)</span>
  1054. <span class="go">365</span>
  1055. </pre></div>
  1056. </div>
  1057. </dd></dl>
  1058. <dl class="function">
  1059. <dt id="ipfml.iqa.fr.rmse">
  1060. <code class="descclassname">ipfml.iqa.fr.</code><code class="descname">rmse</code><span class="sig-paren">(</span><em>img_true</em>, <em>img_test</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.iqa.fr.rmse" title="Permalink to this definition">¶</a></dt>
  1061. <dd><p>Returns Root Mean-Squared Error score between two Numpy arrays</p>
  1062. <table class="docutils field-list" frame="void" rules="none">
  1063. <col class="field-name" />
  1064. <col class="field-body" />
  1065. <tbody valign="top">
  1066. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1067. <li><strong>img_true</strong> – Image, numpy array of any dimension</li>
  1068. <li><strong>img_test</strong> – Image, numpy array of any dimension</li>
  1069. </ul>
  1070. </td>
  1071. </tr>
  1072. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Computed RMSE score</p>
  1073. </td>
  1074. </tr>
  1075. <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">NumpyShapeComparisonException</span></code> – if shape of images are not the same</p>
  1076. </td>
  1077. </tr>
  1078. </tbody>
  1079. </table>
  1080. <p class="rubric">Example</p>
  1081. <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.iqa</span> <span class="k">import</span> <span class="n">fr</span>
  1082. <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>
  1083. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  1084. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr2</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">5</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
  1085. <span class="gp">&gt;&gt;&gt; </span><span class="n">rmse_score</span> <span class="o">=</span> <span class="n">fr</span><span class="o">.</span><span class="n">rmse</span><span class="p">(</span><span class="n">arr1</span><span class="p">,</span> <span class="n">arr2</span><span class="p">)</span>
  1086. <span class="gp">&gt;&gt;&gt; </span><span class="n">rmse_score</span>
  1087. <span class="go">5.0</span>
  1088. </pre></div>
  1089. </div>
  1090. </dd></dl>
  1091. <dl class="function">
  1092. <dt id="ipfml.iqa.fr.vif">
  1093. <code class="descclassname">ipfml.iqa.fr.</code><code class="descname">vif</code><span class="sig-paren">(</span><em>img_true</em>, <em>img_test</em><span class="sig-paren">)</span><a class="headerlink" href="#ipfml.iqa.fr.vif" title="Permalink to this definition">¶</a></dt>
  1094. <dd><p>Implemented later..</p>
  1095. </dd></dl>
  1096. </div>
  1097. </div>
  1098. <div class="section" id="module-ipfml.utils">
  1099. <span id="ipfml-utils"></span><h2>ipfml.utils<a class="headerlink" href="#module-ipfml.utils" title="Permalink to this headline">¶</a></h2>
  1100. <dl class="function">
  1101. <dt id="ipfml.utils.normalize_2D_arr">
  1102. <code class="descclassname">ipfml.utils.</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.utils.normalize_2D_arr" title="Permalink to this definition">¶</a></dt>
  1103. <dd><p>Return array normalize from its min and max values</p>
  1104. <table class="docutils field-list" frame="void" rules="none">
  1105. <col class="field-name" />
  1106. <col class="field-body" />
  1107. <tbody valign="top">
  1108. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – 2D Numpy array</td>
  1109. </tr>
  1110. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 2D Numpy array</td>
  1111. </tr>
  1112. </tbody>
  1113. </table>
  1114. <p>Example:</p>
  1115. <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>
  1116. <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span><span class="p">,</span> <span class="n">processing</span>
  1117. <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>
  1118. <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>
  1119. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span> <span class="o">=</span> <span class="n">utils</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>
  1120. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span><span class="o">.</span><span class="n">shape</span>
  1121. <span class="go">(200, 200)</span>
  1122. </pre></div>
  1123. </div>
  1124. </dd></dl>
  1125. <dl class="function">
  1126. <dt id="ipfml.utils.normalize_arr">
  1127. <code class="descclassname">ipfml.utils.</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.utils.normalize_arr" title="Permalink to this definition">¶</a></dt>
  1128. <dd><p>Normalize data of 1D array shape</p>
  1129. <table class="docutils field-list" frame="void" rules="none">
  1130. <col class="field-name" />
  1131. <col class="field-body" />
  1132. <tbody valign="top">
  1133. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  1134. </tr>
  1135. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D array</td>
  1136. </tr>
  1137. </tbody>
  1138. </table>
  1139. <p>Example:</p>
  1140. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  1141. <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>
  1142. <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>
  1143. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_arr</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
  1144. <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>
  1145. <span class="go">0.1</span>
  1146. </pre></div>
  1147. </div>
  1148. </dd></dl>
  1149. <dl class="function">
  1150. <dt id="ipfml.utils.normalize_arr_with_range">
  1151. <code class="descclassname">ipfml.utils.</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.utils.normalize_arr_with_range" title="Permalink to this definition">¶</a></dt>
  1152. <dd><p>Normalize data of 1D array shape</p>
  1153. <table class="docutils field-list" frame="void" rules="none">
  1154. <col class="field-name" />
  1155. <col class="field-body" />
  1156. <tbody valign="top">
  1157. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  1158. </tr>
  1159. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D Numpy array</td>
  1160. </tr>
  1161. </tbody>
  1162. </table>
  1163. <p>Example:</p>
  1164. <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>
  1165. <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>
  1166. <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>
  1167. <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>
  1168. <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>
  1169. <span class="go">0.05</span>
  1170. </pre></div>
  1171. </div>
  1172. </dd></dl>
  1173. </div>
  1174. <div class="section" id="module-ipfml.exceptions">
  1175. <span id="ipfml-exceptions"></span><h2>ipfml.exceptions<a class="headerlink" href="#module-ipfml.exceptions" title="Permalink to this headline">¶</a></h2>
  1176. <p>Module which contains all customs Exceptions</p>
  1177. <dl class="exception">
  1178. <dt id="ipfml.exceptions.NumpyDimensionComparisonException">
  1179. <em class="property">exception </em><code class="descclassname">ipfml.exceptions.</code><code class="descname">NumpyDimensionComparisonException</code><a class="headerlink" href="#ipfml.exceptions.NumpyDimensionComparisonException" title="Permalink to this definition">¶</a></dt>
  1180. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></p>
  1181. <p>Numpy dimensions comparison Exception raised if two numpy arrays provided do not have same dimensions</p>
  1182. </dd></dl>
  1183. <dl class="exception">
  1184. <dt id="ipfml.exceptions.NumpyShapeComparisonException">
  1185. <em class="property">exception </em><code class="descclassname">ipfml.exceptions.</code><code class="descname">NumpyShapeComparisonException</code><a class="headerlink" href="#ipfml.exceptions.NumpyShapeComparisonException" title="Permalink to this definition">¶</a></dt>
  1186. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></p>
  1187. <p>Numpy shape comparison Exception raised if two numpy arrays provided do not have same shape extactly</p>
  1188. </dd></dl>
  1189. </div>
  1190. </div>
  1191. </div>
  1192. </div>
  1193. <footer>
  1194. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  1195. <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>
  1196. <a href="description.html" class="btn btn-neutral" title="Description" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  1197. </div>
  1198. <hr/>
  1199. <div role="contentinfo">
  1200. <p>
  1201. &copy; Copyright 2019, Jérôme BUISINE
  1202. </p>
  1203. </div>
  1204. 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>.
  1205. </footer>
  1206. </div>
  1207. </div>
  1208. </section>
  1209. </div>
  1210. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  1211. <script type="text/javascript" src="_static/jquery.js"></script>
  1212. <script type="text/javascript" src="_static/underscore.js"></script>
  1213. <script type="text/javascript" src="_static/doctools.js"></script>
  1214. <script type="text/javascript" src="_static/language_data.js"></script>
  1215. <script type="text/javascript" src="_static/js/theme.js"></script>
  1216. <script type="text/javascript">
  1217. jQuery(function () {
  1218. SphinxRtdTheme.Navigation.enable(true);
  1219. });
  1220. </script>
  1221. </body>
  1222. </html>