ipfml.html 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  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-Squared 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 MSE 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</span> <span class="k">import</span> <span class="n">utils</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">10</span><span class="p">)</span>
  984. <span class="gp">&gt;&gt;&gt; </span><span class="n">mse</span> <span class="o">=</span> <span class="n">utils</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>
  985. <span class="gp">&gt;&gt;&gt; </span><span class="n">mse</span>
  986. <span class="go">100</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 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</span> <span class="k">import</span> <span class="n">utils</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">10</span><span class="p">)</span>
  1022. <span class="gp">&gt;&gt;&gt; </span><span class="n">mse</span> <span class="o">=</span> <span class="n">utils</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</span>
  1024. <span class="go">100</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. </dd></dl>
  1048. <dl class="function">
  1049. <dt id="ipfml.iqa.fr.rmse">
  1050. <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>
  1051. <dd><p>Returns Mean-Squared Error between two Numpy arrays</p>
  1052. <table class="docutils field-list" frame="void" rules="none">
  1053. <col class="field-name" />
  1054. <col class="field-body" />
  1055. <tbody valign="top">
  1056. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1057. <li><strong>img_true</strong> – Image, numpy array of any dimension</li>
  1058. <li><strong>img_test</strong> – Image, numpy array of any dimension</li>
  1059. </ul>
  1060. </td>
  1061. </tr>
  1062. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Computed MSE score</p>
  1063. </td>
  1064. </tr>
  1065. <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>
  1066. </td>
  1067. </tr>
  1068. </tbody>
  1069. </table>
  1070. <p class="rubric">Example</p>
  1071. <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>
  1072. <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>
  1073. <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>
  1074. <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">10</span><span class="p">)</span>
  1075. <span class="gp">&gt;&gt;&gt; </span><span class="n">rmse</span> <span class="o">=</span> <span class="n">utils</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>
  1076. <span class="gp">&gt;&gt;&gt; </span><span class="n">rmse</span>
  1077. <span class="go">100</span>
  1078. </pre></div>
  1079. </div>
  1080. </dd></dl>
  1081. <dl class="function">
  1082. <dt id="ipfml.iqa.fr.vif">
  1083. <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>
  1084. <dd><p>Implemented later..</p>
  1085. </dd></dl>
  1086. </div>
  1087. </div>
  1088. <div class="section" id="module-ipfml.utils">
  1089. <span id="ipfml-utils"></span><h2>ipfml.utils<a class="headerlink" href="#module-ipfml.utils" title="Permalink to this headline">¶</a></h2>
  1090. <dl class="function">
  1091. <dt id="ipfml.utils.normalize_2D_arr">
  1092. <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>
  1093. <dd><p>Return array normalize from its min and max values</p>
  1094. <table class="docutils field-list" frame="void" rules="none">
  1095. <col class="field-name" />
  1096. <col class="field-body" />
  1097. <tbody valign="top">
  1098. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – 2D Numpy array</td>
  1099. </tr>
  1100. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 2D Numpy array</td>
  1101. </tr>
  1102. </tbody>
  1103. </table>
  1104. <p>Example:</p>
  1105. <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>
  1106. <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>
  1107. <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>
  1108. <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>
  1109. <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>
  1110. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span><span class="o">.</span><span class="n">shape</span>
  1111. <span class="go">(200, 200)</span>
  1112. </pre></div>
  1113. </div>
  1114. </dd></dl>
  1115. <dl class="function">
  1116. <dt id="ipfml.utils.normalize_arr">
  1117. <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>
  1118. <dd><p>Normalize data of 1D array shape</p>
  1119. <table class="docutils field-list" frame="void" rules="none">
  1120. <col class="field-name" />
  1121. <col class="field-body" />
  1122. <tbody valign="top">
  1123. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  1124. </tr>
  1125. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D array</td>
  1126. </tr>
  1127. </tbody>
  1128. </table>
  1129. <p>Example:</p>
  1130. <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>
  1131. <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>
  1132. <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>
  1133. <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>
  1134. <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>
  1135. <span class="go">0.1</span>
  1136. </pre></div>
  1137. </div>
  1138. </dd></dl>
  1139. <dl class="function">
  1140. <dt id="ipfml.utils.normalize_arr_with_range">
  1141. <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>
  1142. <dd><p>Normalize data of 1D array shape</p>
  1143. <table class="docutils field-list" frame="void" rules="none">
  1144. <col class="field-name" />
  1145. <col class="field-body" />
  1146. <tbody valign="top">
  1147. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  1148. </tr>
  1149. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D Numpy array</td>
  1150. </tr>
  1151. </tbody>
  1152. </table>
  1153. <p>Example:</p>
  1154. <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>
  1155. <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>
  1156. <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>
  1157. <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>
  1158. <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>
  1159. <span class="go">0.05</span>
  1160. </pre></div>
  1161. </div>
  1162. </dd></dl>
  1163. </div>
  1164. <div class="section" id="module-ipfml.exceptions">
  1165. <span id="ipfml-exceptions"></span><h2>ipfml.exceptions<a class="headerlink" href="#module-ipfml.exceptions" title="Permalink to this headline">¶</a></h2>
  1166. <p>Module which contains all customs Exceptions</p>
  1167. <dl class="exception">
  1168. <dt id="ipfml.exceptions.NumpyDimensionComparisonException">
  1169. <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>
  1170. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></p>
  1171. <p>Numpy dimensions comparison Exception raised if two numpy arrays provided do not have same dimensions</p>
  1172. </dd></dl>
  1173. <dl class="exception">
  1174. <dt id="ipfml.exceptions.NumpyShapeComparisonException">
  1175. <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>
  1176. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></p>
  1177. <p>Numpy shape comparison Exception raised if two numpy arrays provided do not have same shape extactly</p>
  1178. </dd></dl>
  1179. </div>
  1180. </div>
  1181. </div>
  1182. </div>
  1183. <footer>
  1184. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  1185. <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>
  1186. <a href="description.html" class="btn btn-neutral" title="Description" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  1187. </div>
  1188. <hr/>
  1189. <div role="contentinfo">
  1190. <p>
  1191. &copy; Copyright 2019, Jérôme BUISINE
  1192. </p>
  1193. </div>
  1194. 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>.
  1195. </footer>
  1196. </div>
  1197. </div>
  1198. </section>
  1199. </div>
  1200. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  1201. <script type="text/javascript" src="_static/jquery.js"></script>
  1202. <script type="text/javascript" src="_static/underscore.js"></script>
  1203. <script type="text/javascript" src="_static/doctools.js"></script>
  1204. <script type="text/javascript" src="_static/language_data.js"></script>
  1205. <script type="text/javascript" src="_static/js/theme.js"></script>
  1206. <script type="text/javascript">
  1207. jQuery(function () {
  1208. SphinxRtdTheme.Navigation.enable(true);
  1209. });
  1210. </script>
  1211. </body>
  1212. </html>