ipfml.html 85 KB

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