123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Image — image features extraction 1.0.0 documentation</title>
- <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
- <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
- <script type="text/javascript">
- var DOCUMENTATION_OPTIONS = {
- URL_ROOT: '../',
- VERSION: '1.0.0',
- COLLAPSE_INDEX: false,
- FILE_SUFFIX: '.html',
- HAS_SOURCE: true,
- SOURCELINK_SUFFIX: '.txt'
- };
- </script>
- <script type="text/javascript" src="../_static/jquery.js"></script>
- <script type="text/javascript" src="../_static/underscore.js"></script>
- <script type="text/javascript" src="../_static/doctools.js"></script>
- <link rel="index" title="Index" href="../genindex.html" />
- <link rel="search" title="Search" href="../search.html" />
-
- <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
-
-
- <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
- </head>
- <body>
-
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <h1>Source code for Image</h1><div class="highlight"><pre>
- <span></span>
- <span class="kn">import</span> <span class="nn">scipy.misc</span> <span class="k">as</span> <span class="nn">sm</span>
- <span class="kn">from</span> <span class="nn">skimage.measure</span> <span class="k">import</span> <span class="n">label</span>
- <span class="kn">from</span> <span class="nn">skimage</span> <span class="k">import</span> <span class="n">filters</span><span class="p">,</span> <span class="n">io</span>
- <span class="kn">from</span> <span class="nn">skimage.segmentation</span> <span class="k">import</span> <span class="n">clear_border</span>
- <span class="kn">from</span> <span class="nn">image_features_extraction</span> <span class="k">import</span> <span class="n">Regions</span>
- <span class="kn">from</span> <span class="nn">image_features_extraction</span> <span class="k">import</span> <span class="n">MyException</span>
- <div class="viewcode-block" id="Image"><a class="viewcode-back" href="../code.html#Image.Image">[docs]</a><span class="k">class</span> <span class="nc">Image</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
- <span class="sd">"""</span>
- <span class="sd"> Class image containing the single image obtained from the collection :class:`Images`</span>
- <span class="sd"> :example:</span>
- <span class="sd"> >>> import image_features_extraction as fe</span>
- <span class="sd"> >>> imgs = fe.Images(folder_name)</span>
- <span class="sd"> >>> img = imgs.item(1)</span>
- <span class="sd"> """</span>
- <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">full_name</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__full_file_name</span> <span class="o">=</span> <span class="n">full_name</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__regions</span> <span class="o">=</span> <span class="kc">None</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__mask</span> <span class="o">=</span> <span class="kc">None</span>
- <span class="k">try</span><span class="p">:</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__get_regions</span><span class="p">()</span>
- <span class="k">except</span> <span class="n">MyException</span><span class="o">.</span><span class="n">MyException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
- <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">)</span>
- <div class="viewcode-block" id="Image.file_name"><a class="viewcode-back" href="../code.html#Image.Image.file_name">[docs]</a> <span class="k">def</span> <span class="nf">file_name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="sd">"""</span>
- <span class="sd"> file_name(...) return the full file name of the image</span>
- <span class="sd"> """</span>
- <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__full_file_name</span></div>
- <div class="viewcode-block" id="Image.regions"><a class="viewcode-back" href="../code.html#Image.Image.regions">[docs]</a> <span class="k">def</span> <span class="nf">regions</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="sd">"""</span>
- <span class="sd"> regions(...) returns the Object Regions</span>
- <span class="sd"> >>> import image_features_extraction as fe</span>
- <span class="sd"> >>> imgs = fe.Images(folder_name)</span>
- <span class="sd"> >>> img = imgs.item(1)</span>
- <span class="sd"> >>> regs = img.Regions()</span>
- <span class="sd"> """</span>
- <span class="k">try</span><span class="p">:</span>
- <span class="n">regs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__get_regions</span><span class="p">()</span>
- <span class="k">return</span> <span class="n">Regions</span><span class="o">.</span><span class="n">Regions</span><span class="p">(</span><span class="n">regs</span><span class="p">)</span>
- <span class="k">except</span> <span class="n">MyException</span><span class="o">.</span><span class="n">MyException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
- <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">)</span>
- <span class="k">return</span> <span class="kc">None</span></div>
- <span class="k">def</span> <span class="nf">__get_regions</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="c1"># load the image</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">image</span> <span class="o">=</span> <span class="n">io</span><span class="o">.</span><span class="n">imread</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_name</span><span class="p">())</span>
- <span class="c1"># ithresholding to build the map</span>
- <span class="n">val</span> <span class="o">=</span> <span class="n">filters</span><span class="o">.</span><span class="n">threshold_otsu</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">image</span><span class="p">)</span>
- <span class="c1"># cretes the mask</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__mask</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">image</span> <span class="o">></span> <span class="n">val</span>
- <span class="c1"># returns the single segmented elements of the image</span>
- <span class="n">labels_segment</span> <span class="o">=</span> <span class="n">label</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__mask</span><span class="p">)</span>
- <span class="c1"># removes the image elements at the border</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__regions</span> <span class="o">=</span> <span class="n">clear_border</span><span class="p">(</span><span class="n">labels_segment</span><span class="p">)</span>
- <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__regions</span></div>
- </pre></div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
- <div class="sphinxsidebarwrapper">
- <h1 class="logo"><a href="../index.html">image features extraction</a></h1>
- <h3>Navigation</h3>
- <p class="caption"><span class="caption-text">Contents:</span></p>
- <ul>
- <li class="toctree-l1"><a class="reference internal" href="../intro.html">Introduction</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../tutorial.html">Tutorial</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../code.html">Classes/Modules</a></li>
- </ul>
- <div class="relations">
- <h3>Related Topics</h3>
- <ul>
- <li><a href="../index.html">Documentation overview</a><ul>
- <li><a href="index.html">Module code</a><ul>
- </ul></li>
- </ul></li>
- </ul>
- </div>
- <div id="searchbox" style="display: none" role="search">
- <h3>Quick search</h3>
- <form class="search" action="../search.html" method="get">
- <div><input type="text" name="q" /></div>
- <div><input type="submit" value="Go" /></div>
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="footer">
- ©2017, Remigio Picone.
-
- |
- Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.3</a>
- & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
-
- </div>
-
-
- </body>
- </html>
|