code.html 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Classes/Modules &#8212; Image Features Extraction 1.0.0 documentation</title>
  7. <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: './',
  12. VERSION: '1.0.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true,
  16. SOURCELINK_SUFFIX: '.txt'
  17. };
  18. </script>
  19. <script type="text/javascript" src="_static/jquery.js"></script>
  20. <script type="text/javascript" src="_static/underscore.js"></script>
  21. <script type="text/javascript" src="_static/doctools.js"></script>
  22. <link rel="index" title="Index" href="genindex.html" />
  23. <link rel="search" title="Search" href="search.html" />
  24. <link rel="prev" title="Tutorial" href="tutorial.html" />
  25. <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  26. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  27. </head>
  28. <body>
  29. <div class="document">
  30. <div class="documentwrapper">
  31. <div class="bodywrapper">
  32. <div class="body" role="main">
  33. <div class="section" id="classes-modules">
  34. <h1>Classes/Modules<a class="headerlink" href="#classes-modules" title="Permalink to this headline">¶</a></h1>
  35. <div class="section" id="module-Images">
  36. <span id="images"></span><h2>Images<a class="headerlink" href="#module-Images" title="Permalink to this headline">¶</a></h2>
  37. <dl class="class">
  38. <dt id="Images.Images">
  39. <em class="property">class </em><code class="descclassname">Images.</code><code class="descname">Images</code><span class="sig-paren">(</span><em>folder_name, image_file_ext=['tif', 'tiff']</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Images.html#Images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Images.Images" title="Permalink to this definition">¶</a></dt>
  40. <dd><p>This class loads a collection of images for extraction of features</p>
  41. <table class="docutils field-list" frame="void" rules="none">
  42. <col class="field-name" />
  43. <col class="field-body" />
  44. <tbody valign="top">
  45. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  46. <li><strong>folder_name</strong> (<em>List of strings</em>) – folder containing images</li>
  47. <li><strong>image_file_ext</strong> – images file extensions (default=[‘tif’,’tiff’])</li>
  48. </ul>
  49. </td>
  50. </tr>
  51. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">an instance of the object Images</p>
  52. </td>
  53. </tr>
  54. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">object</p>
  55. </td>
  56. </tr>
  57. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  58. </tr>
  59. </tbody>
  60. </table>
  61. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  62. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="s1">&#39;my_folder&#39;</span><span class="p">,</span> <span class="n">image_file_ext</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;tif&#39;</span><span class="p">,</span><span class="s1">&#39;tiff&#39;</span><span class="p">,</span><span class="s1">&#39;jpeg&#39;</span><span class="p">])</span>
  63. <span class="gp">&gt;&gt;&gt; </span><span class="n">num_images</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">count</span><span class="p">()</span>
  64. </pre></div>
  65. </div>
  66. <dl class="method">
  67. <dt id="Images.Images.count">
  68. <code class="descname">count</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Images.Images.count" title="Permalink to this definition">¶</a></dt>
  69. <dd><p>returns the number of items</p>
  70. </dd></dl>
  71. <dl class="method">
  72. <dt id="Images.Images.count_update">
  73. <code class="descname">count_update</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#Images.Images.count_update" title="Permalink to this definition">¶</a></dt>
  74. <dd></dd></dl>
  75. <dl class="method">
  76. <dt id="Images.Images.item">
  77. <code class="descname">item</code><span class="sig-paren">(</span><em>i</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Images.html#Images.item"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Images.Images.item" title="Permalink to this definition">¶</a></dt>
  78. <dd><p>returns the i-th image</p>
  79. <table class="docutils field-list" frame="void" rules="none">
  80. <col class="field-name" />
  81. <col class="field-body" />
  82. <tbody valign="top">
  83. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>i</strong> (<em>int</em>) – the i-th image</td>
  84. </tr>
  85. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#module-Image" title="Image"><code class="xref py py-class docutils literal"><span class="pre">Image</span></code></a></td>
  86. </tr>
  87. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">object</td>
  88. </tr>
  89. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  94. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  95. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  96. </pre></div>
  97. </div>
  98. </dd></dl>
  99. </dd></dl>
  100. </div>
  101. <div class="section" id="module-Image">
  102. <span id="image"></span><h2>Image<a class="headerlink" href="#module-Image" title="Permalink to this headline">¶</a></h2>
  103. <dl class="class">
  104. <dt id="Image.Image">
  105. <em class="property">class </em><code class="descclassname">Image.</code><code class="descname">Image</code><span class="sig-paren">(</span><em>full_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image" title="Permalink to this definition">¶</a></dt>
  106. <dd><p>This class instantiate an object Image through the <a class="reference internal" href="#module-Images" title="Images"><code class="xref py py-class docutils literal"><span class="pre">Images</span></code></a> and refers to a specific file image</p>
  107. <table class="docutils field-list" frame="void" rules="none">
  108. <col class="field-name" />
  109. <col class="field-body" />
  110. <tbody valign="top">
  111. <tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td>
  112. </tr>
  113. </tbody>
  114. </table>
  115. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  116. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  117. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  118. </pre></div>
  119. </div>
  120. <dl class="method">
  121. <dt id="Image.Image.Voronoi">
  122. <code class="descname">Voronoi</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.Voronoi"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.Voronoi" title="Permalink to this definition">¶</a></dt>
  123. <dd><p>Image Voronoi diagram (refer to documentaiton of my package Voronoi_Features in my github )</p>
  124. <table class="docutils field-list" frame="void" rules="none">
  125. <col class="field-name" />
  126. <col class="field-body" />
  127. <tbody valign="top">
  128. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Voronoi object for the current image</td>
  129. </tr>
  130. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">Voronoi object</td>
  131. </tr>
  132. </tbody>
  133. </table>
  134. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
  135. <span class="go">&gt;&gt;&gt;</span>
  136. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  137. <span class="go">&gt;&gt;&gt;</span>
  138. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  139. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  140. <span class="go">&gt;&gt;&gt;</span>
  141. <span class="gp">&gt;&gt;&gt; </span><span class="n">voro</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Voronoi</span><span class="p">()</span>
  142. <span class="gp">&gt;&gt;&gt; </span><span class="c1"># show voronoi diagram</span>
  143. <span class="gp">&gt;&gt;&gt; </span><span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span><span class="mi">20</span><span class="p">))</span>
  144. <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><span class="n">vor</span><span class="o">.</span><span class="n">get_voronoi_map</span><span class="p">(),</span> <span class="n">cmap</span><span class="o">=</span><span class="n">plt</span><span class="o">.</span><span class="n">get_cmap</span><span class="p">(</span><span class="s1">&#39;jet&#39;</span><span class="p">))</span>
  145. </pre></div>
  146. </div>
  147. </dd></dl>
  148. <dl class="method">
  149. <dt id="Image.Image.features">
  150. <code class="descname">features</code><span class="sig-paren">(</span><em>features_list</em>, <em>prefix=''</em>, <em>suffix=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.features"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.features" title="Permalink to this definition">¶</a></dt>
  151. <dd><p>Returns a table with all values for the property names given in input, and supplies an
  152. additional parameter for feature classification</p>
  153. <table class="docutils field-list" frame="void" rules="none">
  154. <col class="field-name" />
  155. <col class="field-body" />
  156. <tbody valign="top">
  157. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  158. <li><strong>features_list</strong> (<em>List</em>) – list of property/measure names (e.g, ‘area’, ‘centroid’, etc )</li>
  159. <li><strong>prefix</strong> (<em>string</em>) – prefix for features name</li>
  160. <li><strong>suffix</strong> (<em>string</em>) – prefix for features name</li>
  161. </ul>
  162. </td>
  163. </tr>
  164. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Features Object</p>
  165. </td>
  166. </tr>
  167. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">Features Object</p>
  168. </td>
  169. </tr>
  170. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  175. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  176. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  177. <span class="gp">&gt;&gt;&gt; </span><span class="n">feature</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">get_features</span><span class="p">([</span><span class="s1">&#39;label&#39;</span><span class="p">,</span> <span class="s1">&#39;area&#39;</span><span class="p">,</span><span class="s1">&#39;perimeter&#39;</span><span class="p">,</span> <span class="s1">&#39;centroid&#39;</span><span class="p">])</span>
  178. </pre></div>
  179. </div>
  180. </dd></dl>
  181. <dl class="method">
  182. <dt id="Image.Image.file_name">
  183. <code class="descname">file_name</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.file_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.file_name" title="Permalink to this definition">¶</a></dt>
  184. <dd><p>full file name of the image</p>
  185. <table class="docutils field-list" frame="void" rules="none">
  186. <col class="field-name" />
  187. <col class="field-body" />
  188. <tbody valign="top">
  189. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">file name</td>
  190. </tr>
  191. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. </dd></dl>
  196. <dl class="method">
  197. <dt id="Image.Image.get_image_segmentation">
  198. <code class="descname">get_image_segmentation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.get_image_segmentation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.get_image_segmentation" title="Permalink to this definition">¶</a></dt>
  199. <dd><p>Builds the image with mask overlay to show the segmentation</p>
  200. <table class="docutils field-list" frame="void" rules="none">
  201. <col class="field-name" />
  202. <col class="field-body" />
  203. <tbody valign="top">
  204. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The image in RGB format, in a 3-D array of shape (.., .., 3).</td>
  205. </tr>
  206. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">ndarray</td>
  207. </tr>
  208. </tbody>
  209. </table>
  210. </dd></dl>
  211. <dl class="method">
  212. <dt id="Image.Image.height">
  213. <code class="descname">height</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.height"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.height" title="Permalink to this definition">¶</a></dt>
  214. <dd></dd></dl>
  215. <dl class="method">
  216. <dt id="Image.Image.prop_values">
  217. <code class="descname">prop_values</code><span class="sig-paren">(</span><em>prop_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.prop_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.prop_values" title="Permalink to this definition">¶</a></dt>
  218. <dd><p>Measure the values of the specified property/measure name (e.g., ‘area’) for all
  219. elements contained in the object Regions.</p>
  220. <table class="docutils field-list" frame="void" rules="none">
  221. <col class="field-name" />
  222. <col class="field-body" />
  223. <tbody valign="top">
  224. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>prop_name</strong> (<em>string</em>) – name of the property to measure (e.g, ‘area’)</td>
  225. </tr>
  226. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">property name values</td>
  227. </tr>
  228. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">List</td>
  229. </tr>
  230. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  235. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  236. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  237. <span class="gp">&gt;&gt;&gt; </span><span class="n">regs</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span>
  238. <span class="gp">&gt;&gt;&gt; </span><span class="n">areas</span> <span class="o">=</span> <span class="n">regs</span><span class="o">.</span><span class="n">prop_values</span><span class="p">(</span><span class="s1">&#39;area&#39;</span><span class="p">)</span>
  239. </pre></div>
  240. </div>
  241. <p>The following properties can be accessed as attributes or keys:</p>
  242. <dl class="docutils">
  243. <dt><strong>area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  244. <dd>Number of pixels of region.</dd>
  245. <dt><strong>bbox</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  246. <dd>Bounding box <code class="docutils literal"><span class="pre">(min_row,</span> <span class="pre">min_col,</span> <span class="pre">max_row,</span> <span class="pre">max_col)</span></code>.
  247. Pixels belonging to the bounding box are in the half-open interval
  248. <code class="docutils literal"><span class="pre">[min_row;</span> <span class="pre">max_row)</span></code> and <code class="docutils literal"><span class="pre">[min_col;</span> <span class="pre">max_col)</span></code>.</dd>
  249. <dt><strong>bbox_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  250. <dd>Number of pixels of bounding box.</dd>
  251. <dt><strong>centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  252. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>.</dd>
  253. <dt><strong>convex_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  254. <dd>Number of pixels of convex hull image.</dd>
  255. <dt><strong>convex_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  256. <dd>Binary convex hull image which has the same size as bounding box.</dd>
  257. <dt><strong>coords</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(N, 2) ndarray</span></dt>
  258. <dd>Coordinate list <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code> of the region.</dd>
  259. <dt><strong>eccentricity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  260. <dd>Eccentricity of the ellipse that has the same second-moments as the
  261. region. The eccentricity is the ratio of the focal distance
  262. (distance between focal points) over the major axis length.
  263. The value is in the interval [0, 1).
  264. When it is 0, the ellipse becomes a circle.</dd>
  265. <dt><strong>equivalent_diameter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  266. <dd>The diameter of a circle with the same area as the region.</dd>
  267. <dt><strong>euler_number</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  268. <dd>Euler characteristic of region. Computed as number of objects (= 1)
  269. subtracted by number of holes (8-connectivity).</dd>
  270. <dt><strong>extent</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  271. <dd>Ratio of pixels in the region to pixels in the total bounding box.
  272. Computed as <code class="docutils literal"><span class="pre">area</span> <span class="pre">/</span> <span class="pre">(rows</span> <span class="pre">*</span> <span class="pre">cols)</span></code></dd>
  273. <dt><strong>filled_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  274. <dd>Number of pixels of filled region.</dd>
  275. <dt><strong>filled_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  276. <dd>Binary region image with filled holes which has the same size as
  277. bounding box.</dd>
  278. <dt><strong>image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  279. <dd>Sliced binary region image which has the same size as bounding box.</dd>
  280. <dt><strong>inertia_tensor</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(2, 2) ndarray</span></dt>
  281. <dd>Inertia tensor of the region for the rotation around its mass.</dd>
  282. <dt><strong>inertia_tensor_eigvals</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  283. <dd>The two eigen values of the inertia tensor in decreasing order.</dd>
  284. <dt><strong>intensity_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">ndarray</span></dt>
  285. <dd>Image inside region bounding box.</dd>
  286. <dt><strong>label</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  287. <dd>The label in the labeled input image.</dd>
  288. <dt><strong>local_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  289. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>, relative to region bounding
  290. box.</dd>
  291. <dt><strong>major_axis_length</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  292. <dd>The length of the major axis of the ellipse that has the same
  293. normalized second central moments as the region.</dd>
  294. <dt><strong>max_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  295. <dd>Value with the greatest intensity in the region.</dd>
  296. <dt><strong>mean_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  297. <dd>Value with the mean intensity in the region.</dd>
  298. <dt><strong>min_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  299. <dd>Value with the least intensity in the region.</dd>
  300. <dt><strong>minor_axis_length</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  301. <dd>The length of the minor axis of the ellipse that has the same
  302. normalized second central moments as the region.</dd>
  303. <dt><strong>moments</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  304. <dd><dl class="first docutils">
  305. <dt>Spatial moments up to 3rd order::</dt>
  306. <dd>m_ji = sum{ array(x, y) * x^j * y^i }</dd>
  307. </dl>
  308. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region.</p>
  309. </dd>
  310. <dt><strong>moments_central</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  311. <dd><dl class="first docutils">
  312. <dt>Central moments (translation invariant) up to 3rd order::</dt>
  313. <dd>mu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }</dd>
  314. </dl>
  315. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region,
  316. and <cite>x_c</cite> and <cite>y_c</cite> are the coordinates of the region’s centroid.</p>
  317. </dd>
  318. <dt><strong>moments_hu</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  319. <dd>Hu moments (translation, scale and rotation invariant).</dd>
  320. <dt><strong>moments_normalized</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  321. <dd><dl class="first docutils">
  322. <dt>Normalized moments (translation and scale invariant) up to 3rd order::</dt>
  323. <dd>nu_ji = mu_ji / m_00^[(i+j)/2 + 1]</dd>
  324. </dl>
  325. <p class="last">where <cite>m_00</cite> is the zeroth spatial moment.</p>
  326. </dd>
  327. <dt><strong>orientation</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  328. <dd>Angle between the X-axis and the major axis of the ellipse that has
  329. the same second-moments as the region. Ranging from <cite>-pi/2</cite> to
  330. <cite>pi/2</cite> in counter-clockwise direction.</dd>
  331. <dt><strong>perimeter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  332. <dd>Perimeter of object which approximates the contour as a line
  333. through the centers of border pixels using a 4-connectivity.</dd>
  334. <dt><strong>solidity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  335. <dd>Ratio of pixels in the region to pixels of the convex hull image.</dd>
  336. <dt><strong>weighted_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  337. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code> weighted with intensity
  338. image.</dd>
  339. <dt><strong>weighted_local_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  340. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>, relative to region bounding
  341. box, weighted with intensity image.</dd>
  342. <dt><strong>weighted_moments</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  343. <dd><dl class="first docutils">
  344. <dt>Spatial moments of intensity image up to 3rd order::</dt>
  345. <dd>wm_ji = sum{ array(x, y) * x^j * y^i }</dd>
  346. </dl>
  347. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region.</p>
  348. </dd>
  349. <dt><strong>weighted_moments_central</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  350. <dd><p class="first">Central moments (translation invariant) of intensity image up to
  351. 3rd order:</p>
  352. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wmu_ji</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">{</span> <span class="n">array</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">x_c</span><span class="p">)</span><span class="o">^</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">y</span> <span class="o">-</span> <span class="n">y_c</span><span class="p">)</span><span class="o">^</span><span class="n">i</span> <span class="p">}</span>
  353. </pre></div>
  354. </div>
  355. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region,
  356. and <cite>x_c</cite> and <cite>y_c</cite> are the coordinates of the region’s weighted
  357. centroid.</p>
  358. </dd>
  359. <dt><strong>weighted_moments_hu</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  360. <dd>Hu moments (translation, scale and rotation invariant) of intensity
  361. image.</dd>
  362. <dt><strong>weighted_moments_normalized</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  363. <dd><p class="first">Normalized moments (translation and scale invariant) of intensity
  364. image up to 3rd order:</p>
  365. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wnu_ji</span> <span class="o">=</span> <span class="n">wmu_ji</span> <span class="o">/</span> <span class="n">wm_00</span><span class="o">^</span><span class="p">[(</span><span class="n">i</span><span class="o">+</span><span class="n">j</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
  366. </pre></div>
  367. </div>
  368. <p class="last">where <code class="docutils literal"><span class="pre">wm_00</span></code> is the zeroth spatial moment (intensity-weighted area).</p>
  369. </dd>
  370. </dl>
  371. <table class="docutils footnote" frame="void" id="id1" rules="none">
  372. <colgroup><col class="label" /><col /></colgroup>
  373. <tbody valign="top">
  374. <tr><td class="label">[1]</td><td><a class="reference external" href="http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops">http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops</a></td></tr>
  375. </tbody>
  376. </table>
  377. </dd></dl>
  378. <dl class="method">
  379. <dt id="Image.Image.regions">
  380. <code class="descname">regions</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.regions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.regions" title="Permalink to this definition">¶</a></dt>
  381. <dd><p>regions(…) returns the Object Regions</p>
  382. <table class="docutils field-list" frame="void" rules="none">
  383. <col class="field-name" />
  384. <col class="field-body" />
  385. <tbody valign="top">
  386. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#module-Regions" title="Regions"><code class="xref py py-class docutils literal"><span class="pre">Regions</span></code></a></td>
  387. </tr>
  388. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
  389. </tr>
  390. </tbody>
  391. </table>
  392. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  393. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  394. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  395. <span class="gp">&gt;&gt;&gt; </span><span class="n">regs</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span>
  396. </pre></div>
  397. </div>
  398. </dd></dl>
  399. <dl class="method">
  400. <dt id="Image.Image.set_image_intensity">
  401. <code class="descname">set_image_intensity</code><span class="sig-paren">(</span><em>image_intensity</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.set_image_intensity"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.set_image_intensity" title="Permalink to this definition">¶</a></dt>
  402. <dd><p>Sets the image to measurs image’s region intensity properties (e.g, mean_intensity)</p>
  403. <p>: param image_intensity: Image object for intensity measurement
  404. : type image_intensity: Object Image
  405. :returns: the set Image object for intensity measurement
  406. :rtype: Object Image
  407. &gt;&gt;&gt; import image_features_extraction as fe
  408. &gt;&gt;&gt; imgs = fe.Images(folder_name)
  409. &gt;&gt;&gt; img = imgs.item(1) # this is the binary image used for segmentation
  410. &gt;&gt;&gt; img_intensity = imgs.item(0) # this is the original image on which to measure intensities
  411. &gt;&gt;&gt; img.set_image_intensity(img_intensity)
  412. &gt;&gt;&gt; features = IMG.features([‘label’, ‘area’,’perimeter’, ‘centroid’,’major_axis_length’, ‘moments’,’mean_intensity’], class_value=5)</p>
  413. </dd></dl>
  414. <dl class="method">
  415. <dt id="Image.Image.width">
  416. <code class="descname">width</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Image.html#Image.width"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Image.Image.width" title="Permalink to this definition">¶</a></dt>
  417. <dd></dd></dl>
  418. </dd></dl>
  419. </div>
  420. <div class="section" id="module-Regions">
  421. <span id="regions"></span><h2>Regions<a class="headerlink" href="#module-Regions" title="Permalink to this headline">¶</a></h2>
  422. <dl class="class">
  423. <dt id="Regions.Regions">
  424. <em class="property">class </em><code class="descclassname">Regions.</code><code class="descname">Regions</code><span class="sig-paren">(</span><em>obj_regions</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Regions.html#Regions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Regions.Regions" title="Permalink to this definition">¶</a></dt>
  425. <dd><p>This class represent a collection of regions: segmented image elements
  426. It cannot be instanced directly. It is returned from the object <a class="reference internal" href="#module-Image" title="Image"><code class="xref py py-class docutils literal"><span class="pre">Image</span></code></a> through the function
  427. Regions(…)</p>
  428. <table class="docutils field-list" frame="void" rules="none">
  429. <col class="field-name" />
  430. <col class="field-body" />
  431. <tbody valign="top">
  432. <tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td>
  433. </tr>
  434. </tbody>
  435. </table>
  436. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  437. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  438. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  439. <span class="gp">&gt;&gt;&gt; </span><span class="n">regs</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span>
  440. </pre></div>
  441. </div>
  442. <dl class="method">
  443. <dt id="Regions.Regions.count">
  444. <code class="descname">count</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Regions.Regions.count" title="Permalink to this definition">¶</a></dt>
  445. <dd><p>returns the number of items</p>
  446. </dd></dl>
  447. <dl class="method">
  448. <dt id="Regions.Regions.count_update">
  449. <code class="descname">count_update</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#Regions.Regions.count_update" title="Permalink to this definition">¶</a></dt>
  450. <dd></dd></dl>
  451. <dl class="method">
  452. <dt id="Regions.Regions.features">
  453. <code class="descname">features</code><span class="sig-paren">(</span><em>feature_list</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Regions.html#Regions.features"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Regions.Regions.features" title="Permalink to this definition">¶</a></dt>
  454. <dd><p>get_features(…) returns a table with all values for the property names given in input, and supplies an
  455. additional parameter for feature classification</p>
  456. <table class="docutils field-list" frame="void" rules="none">
  457. <col class="field-name" />
  458. <col class="field-body" />
  459. <tbody valign="top">
  460. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  461. <li><strong>features</strong> (<em>List</em>) – list of property/measure names (e.g, ‘area’, ‘centroid’, etc )</li>
  462. <li><strong>class_value</strong> (<em>int</em><em>, </em><em>string</em><em> (</em><em>default=None</em><em>)</em>) – classification label</li>
  463. </ul>
  464. </td>
  465. </tr>
  466. </tbody>
  467. </table>
  468. <p>: param image_mask: expernal Image mask to be used for the segmentation
  469. :type image_mask: Image
  470. :returns: table cointaining all property values (columns) for all elements in the regions object (rows)
  471. :rtype: Pandas.DataFrame
  472. :example:
  473. &gt;&gt;&gt; import image_features_extraction as fe
  474. &gt;&gt;&gt; imgs = fe.Images(folder_name)
  475. &gt;&gt;&gt; img = imgs.item(1)
  476. &gt;&gt;&gt; regs = img.Regions()
  477. &gt;&gt;&gt; feature = regs.get_features([‘label’, ‘area’,’perimeter’, ‘centroid’], class_value=1)
  478. &gt;&gt;&gt;
  479. &gt;&gt;&gt; # external image mask
  480. &gt;&gt;&gt; img_masks = fe.Images(folder_name)
  481. &gt;&gt;&gt; features = regs.get_features([‘label’, ‘area’,’perimeter’, ‘centroid’], class_value=1, image_mask=img_masks.item(1))</p>
  482. </dd></dl>
  483. <dl class="method">
  484. <dt id="Regions.Regions.item">
  485. <code class="descname">item</code><span class="sig-paren">(</span><em>i</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Regions.html#Regions.item"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Regions.Regions.item" title="Permalink to this definition">¶</a></dt>
  486. <dd><p>Item(..) returns the i-th image element of the regions.</p>
  487. <table class="docutils field-list" frame="void" rules="none">
  488. <col class="field-name" />
  489. <col class="field-body" />
  490. <tbody valign="top">
  491. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>i</strong> (<em>int</em>) – the i-th element of the collection region</td>
  492. </tr>
  493. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Region</td>
  494. </tr>
  495. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">object</td>
  496. </tr>
  497. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  498. </tr>
  499. </tbody>
  500. </table>
  501. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  502. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  503. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  504. <span class="gp">&gt;&gt;&gt; </span><span class="n">regs</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span>
  505. <span class="gp">&gt;&gt;&gt; </span><span class="n">reg</span> <span class="o">=</span> <span class="n">regs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  506. </pre></div>
  507. </div>
  508. </dd></dl>
  509. <dl class="method">
  510. <dt id="Regions.Regions.prop_values">
  511. <code class="descname">prop_values</code><span class="sig-paren">(</span><em>prop_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Regions.html#Regions.prop_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Regions.Regions.prop_values" title="Permalink to this definition">¶</a></dt>
  512. <dd><p>Measure the values of the specified property/measure name (e.g., ‘area’) for all
  513. elements contained in the object Regions.</p>
  514. <table class="docutils field-list" frame="void" rules="none">
  515. <col class="field-name" />
  516. <col class="field-body" />
  517. <tbody valign="top">
  518. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>prop_name</strong> (<em>string</em>) – name of the property to measure (e.g, ‘area’)</td>
  519. </tr>
  520. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">property name values</td>
  521. </tr>
  522. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">List</td>
  523. </tr>
  524. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  525. </tr>
  526. </tbody>
  527. </table>
  528. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  529. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  530. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  531. <span class="gp">&gt;&gt;&gt; </span><span class="n">regs</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span>
  532. <span class="gp">&gt;&gt;&gt; </span><span class="n">areas</span> <span class="o">=</span> <span class="n">regs</span><span class="o">.</span><span class="n">prop_values</span><span class="p">(</span><span class="s1">&#39;area&#39;</span><span class="p">)</span>
  533. </pre></div>
  534. </div>
  535. <p>The following properties can be accessed as attributes or keys:</p>
  536. <dl class="docutils">
  537. <dt><strong>area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  538. <dd>Number of pixels of region.</dd>
  539. <dt><strong>bbox</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  540. <dd>Bounding box <code class="docutils literal"><span class="pre">(min_row,</span> <span class="pre">min_col,</span> <span class="pre">max_row,</span> <span class="pre">max_col)</span></code>.
  541. Pixels belonging to the bounding box are in the half-open interval
  542. <code class="docutils literal"><span class="pre">[min_row;</span> <span class="pre">max_row)</span></code> and <code class="docutils literal"><span class="pre">[min_col;</span> <span class="pre">max_col)</span></code>.</dd>
  543. <dt><strong>bbox_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  544. <dd>Number of pixels of bounding box.</dd>
  545. <dt><strong>centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  546. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>.</dd>
  547. <dt><strong>convex_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  548. <dd>Number of pixels of convex hull image.</dd>
  549. <dt><strong>convex_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  550. <dd>Binary convex hull image which has the same size as bounding box.</dd>
  551. <dt><strong>coords</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(N, 2) ndarray</span></dt>
  552. <dd>Coordinate list <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code> of the region.</dd>
  553. <dt><strong>eccentricity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  554. <dd>Eccentricity of the ellipse that has the same second-moments as the
  555. region. The eccentricity is the ratio of the focal distance
  556. (distance between focal points) over the major axis length.
  557. The value is in the interval [0, 1).
  558. When it is 0, the ellipse becomes a circle.</dd>
  559. <dt><strong>equivalent_diameter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  560. <dd>The diameter of a circle with the same area as the region.</dd>
  561. <dt><strong>euler_number</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  562. <dd>Euler characteristic of region. Computed as number of objects (= 1)
  563. subtracted by number of holes (8-connectivity).</dd>
  564. <dt><strong>extent</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  565. <dd>Ratio of pixels in the region to pixels in the total bounding box.
  566. Computed as <code class="docutils literal"><span class="pre">area</span> <span class="pre">/</span> <span class="pre">(rows</span> <span class="pre">*</span> <span class="pre">cols)</span></code></dd>
  567. <dt><strong>filled_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  568. <dd>Number of pixels of filled region.</dd>
  569. <dt><strong>filled_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  570. <dd>Binary region image with filled holes which has the same size as
  571. bounding box.</dd>
  572. <dt><strong>image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  573. <dd>Sliced binary region image which has the same size as bounding box.</dd>
  574. <dt><strong>inertia_tensor</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(2, 2) ndarray</span></dt>
  575. <dd>Inertia tensor of the region for the rotation around its mass.</dd>
  576. <dt><strong>inertia_tensor_eigvals</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  577. <dd>The two eigen values of the inertia tensor in decreasing order.</dd>
  578. <dt><strong>intensity_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">ndarray</span></dt>
  579. <dd>Image inside region bounding box.</dd>
  580. <dt><strong>label</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  581. <dd>The label in the labeled input image.</dd>
  582. <dt><strong>local_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  583. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>, relative to region bounding
  584. box.</dd>
  585. <dt><strong>major_axis_length</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  586. <dd>The length of the major axis of the ellipse that has the same
  587. normalized second central moments as the region.</dd>
  588. <dt><strong>max_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  589. <dd>Value with the greatest intensity in the region.</dd>
  590. <dt><strong>mean_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  591. <dd>Value with the mean intensity in the region.</dd>
  592. <dt><strong>min_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  593. <dd>Value with the least intensity in the region.</dd>
  594. <dt><strong>minor_axis_length</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  595. <dd>The length of the minor axis of the ellipse that has the same
  596. normalized second central moments as the region.</dd>
  597. <dt><strong>moments</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  598. <dd><dl class="first docutils">
  599. <dt>Spatial moments up to 3rd order::</dt>
  600. <dd>m_ji = sum{ array(x, y) * x^j * y^i }</dd>
  601. </dl>
  602. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region.</p>
  603. </dd>
  604. <dt><strong>moments_central</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  605. <dd><dl class="first docutils">
  606. <dt>Central moments (translation invariant) up to 3rd order::</dt>
  607. <dd>mu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }</dd>
  608. </dl>
  609. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region,
  610. and <cite>x_c</cite> and <cite>y_c</cite> are the coordinates of the region’s centroid.</p>
  611. </dd>
  612. <dt><strong>moments_hu</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  613. <dd>Hu moments (translation, scale and rotation invariant).</dd>
  614. <dt><strong>moments_normalized</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  615. <dd><dl class="first docutils">
  616. <dt>Normalized moments (translation and scale invariant) up to 3rd order::</dt>
  617. <dd>nu_ji = mu_ji / m_00^[(i+j)/2 + 1]</dd>
  618. </dl>
  619. <p class="last">where <cite>m_00</cite> is the zeroth spatial moment.</p>
  620. </dd>
  621. <dt><strong>orientation</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  622. <dd>Angle between the X-axis and the major axis of the ellipse that has
  623. the same second-moments as the region. Ranging from <cite>-pi/2</cite> to
  624. <cite>pi/2</cite> in counter-clockwise direction.</dd>
  625. <dt><strong>perimeter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  626. <dd>Perimeter of object which approximates the contour as a line
  627. through the centers of border pixels using a 4-connectivity.</dd>
  628. <dt><strong>solidity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  629. <dd>Ratio of pixels in the region to pixels of the convex hull image.</dd>
  630. <dt><strong>weighted_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  631. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code> weighted with intensity
  632. image.</dd>
  633. <dt><strong>weighted_local_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  634. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>, relative to region bounding
  635. box, weighted with intensity image.</dd>
  636. <dt><strong>weighted_moments</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  637. <dd><dl class="first docutils">
  638. <dt>Spatial moments of intensity image up to 3rd order::</dt>
  639. <dd>wm_ji = sum{ array(x, y) * x^j * y^i }</dd>
  640. </dl>
  641. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region.</p>
  642. </dd>
  643. <dt><strong>weighted_moments_central</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  644. <dd><p class="first">Central moments (translation invariant) of intensity image up to
  645. 3rd order:</p>
  646. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wmu_ji</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">{</span> <span class="n">array</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">x_c</span><span class="p">)</span><span class="o">^</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">y</span> <span class="o">-</span> <span class="n">y_c</span><span class="p">)</span><span class="o">^</span><span class="n">i</span> <span class="p">}</span>
  647. </pre></div>
  648. </div>
  649. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region,
  650. and <cite>x_c</cite> and <cite>y_c</cite> are the coordinates of the region’s weighted
  651. centroid.</p>
  652. </dd>
  653. <dt><strong>weighted_moments_hu</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  654. <dd>Hu moments (translation, scale and rotation invariant) of intensity
  655. image.</dd>
  656. <dt><strong>weighted_moments_normalized</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  657. <dd><p class="first">Normalized moments (translation and scale invariant) of intensity
  658. image up to 3rd order:</p>
  659. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wnu_ji</span> <span class="o">=</span> <span class="n">wmu_ji</span> <span class="o">/</span> <span class="n">wm_00</span><span class="o">^</span><span class="p">[(</span><span class="n">i</span><span class="o">+</span><span class="n">j</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
  660. </pre></div>
  661. </div>
  662. <p class="last">where <code class="docutils literal"><span class="pre">wm_00</span></code> is the zeroth spatial moment (intensity-weighted area).</p>
  663. </dd>
  664. </dl>
  665. <table class="docutils footnote" frame="void" id="id2" rules="none">
  666. <colgroup><col class="label" /><col /></colgroup>
  667. <tbody valign="top">
  668. <tr><td class="label">[1]</td><td><a class="reference external" href="http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops">http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops</a></td></tr>
  669. </tbody>
  670. </table>
  671. </dd></dl>
  672. </dd></dl>
  673. </div>
  674. <div class="section" id="module-Region">
  675. <span id="region"></span><h2>Region<a class="headerlink" href="#module-Region" title="Permalink to this headline">¶</a></h2>
  676. <dl class="class">
  677. <dt id="Region.Region">
  678. <em class="property">class </em><code class="descclassname">Region.</code><code class="descname">Region</code><span class="sig-paren">(</span><em>obj_region</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Region.html#Region"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Region.Region" title="Permalink to this definition">¶</a></dt>
  679. <dd><p>Object refering to a single image region</p>
  680. <dl class="method">
  681. <dt id="Region.Region.prop_value">
  682. <code class="descname">prop_value</code><span class="sig-paren">(</span><em>prop_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Region.html#Region.prop_value"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Region.Region.prop_value" title="Permalink to this definition">¶</a></dt>
  683. <dd><p>Measure the specified property name (e.g., ‘area’)</p>
  684. <table class="docutils field-list" frame="void" rules="none">
  685. <col class="field-name" />
  686. <col class="field-body" />
  687. <tbody valign="top">
  688. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>prop_name</strong> (<em>string</em>) – name of the property to measure (e.g, ‘area’)</td>
  689. </tr>
  690. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">value of the property name</td>
  691. </tr>
  692. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">int,float,list</td>
  693. </tr>
  694. <tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td>
  695. </tr>
  696. </tbody>
  697. </table>
  698. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  699. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  700. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  701. <span class="gp">&gt;&gt;&gt; </span><span class="n">regs</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span>
  702. <span class="gp">&gt;&gt;&gt; </span><span class="n">reg</span> <span class="o">=</span> <span class="n">regs</span><span class="o">.</span><span class="n">Region</span><span class="p">()</span>
  703. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span> <span class="o">=</span> <span class="n">reg</span><span class="o">.</span><span class="n">prop_value</span><span class="p">(</span><span class="s1">&#39;area&#39;</span><span class="p">)</span>
  704. </pre></div>
  705. </div>
  706. <p>The following properties can be accessed as attributes or keys:</p>
  707. <dl class="docutils">
  708. <dt><strong>area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  709. <dd>Number of pixels of region.</dd>
  710. <dt><strong>bbox</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  711. <dd>Bounding box <code class="docutils literal"><span class="pre">(min_row,</span> <span class="pre">min_col,</span> <span class="pre">max_row,</span> <span class="pre">max_col)</span></code>.
  712. Pixels belonging to the bounding box are in the half-open interval
  713. <code class="docutils literal"><span class="pre">[min_row;</span> <span class="pre">max_row)</span></code> and <code class="docutils literal"><span class="pre">[min_col;</span> <span class="pre">max_col)</span></code>.</dd>
  714. <dt><strong>bbox_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  715. <dd>Number of pixels of bounding box.</dd>
  716. <dt><strong>centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  717. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>.</dd>
  718. <dt><strong>convex_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  719. <dd>Number of pixels of convex hull image.</dd>
  720. <dt><strong>convex_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  721. <dd>Binary convex hull image which has the same size as bounding box.</dd>
  722. <dt><strong>coords</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(N, 2) ndarray</span></dt>
  723. <dd>Coordinate list <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code> of the region.</dd>
  724. <dt><strong>eccentricity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  725. <dd>Eccentricity of the ellipse that has the same second-moments as the
  726. region. The eccentricity is the ratio of the focal distance
  727. (distance between focal points) over the major axis length.
  728. The value is in the interval [0, 1).
  729. When it is 0, the ellipse becomes a circle.</dd>
  730. <dt><strong>equivalent_diameter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  731. <dd>The diameter of a circle with the same area as the region.</dd>
  732. <dt><strong>euler_number</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  733. <dd>Euler characteristic of region. Computed as number of objects (= 1)
  734. subtracted by number of holes (8-connectivity).</dd>
  735. <dt><strong>extent</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  736. <dd>Ratio of pixels in the region to pixels in the total bounding box.
  737. Computed as <code class="docutils literal"><span class="pre">area</span> <span class="pre">/</span> <span class="pre">(rows</span> <span class="pre">*</span> <span class="pre">cols)</span></code></dd>
  738. <dt><strong>filled_area</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  739. <dd>Number of pixels of filled region.</dd>
  740. <dt><strong>filled_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  741. <dd>Binary region image with filled holes which has the same size as
  742. bounding box.</dd>
  743. <dt><strong>image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(H, J) ndarray</span></dt>
  744. <dd>Sliced binary region image which has the same size as bounding box.</dd>
  745. <dt><strong>inertia_tensor</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(2, 2) ndarray</span></dt>
  746. <dd>Inertia tensor of the region for the rotation around its mass.</dd>
  747. <dt><strong>inertia_tensor_eigvals</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  748. <dd>The two eigen values of the inertia tensor in decreasing order.</dd>
  749. <dt><strong>intensity_image</strong> <span class="classifier-delimiter">:</span> <span class="classifier">ndarray</span></dt>
  750. <dd>Image inside region bounding box.</dd>
  751. <dt><strong>label</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  752. <dd>The label in the labeled input image.</dd>
  753. <dt><strong>local_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  754. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>, relative to region bounding
  755. box.</dd>
  756. <dt><strong>major_axis_length</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  757. <dd>The length of the major axis of the ellipse that has the same
  758. normalized second central moments as the region.</dd>
  759. <dt><strong>max_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  760. <dd>Value with the greatest intensity in the region.</dd>
  761. <dt><strong>mean_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  762. <dd>Value with the mean intensity in the region.</dd>
  763. <dt><strong>min_intensity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  764. <dd>Value with the least intensity in the region.</dd>
  765. <dt><strong>minor_axis_length</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  766. <dd>The length of the minor axis of the ellipse that has the same
  767. normalized second central moments as the region.</dd>
  768. <dt><strong>moments</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  769. <dd><dl class="first docutils">
  770. <dt>Spatial moments up to 3rd order::</dt>
  771. <dd>m_ji = sum{ array(x, y) * x^j * y^i }</dd>
  772. </dl>
  773. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region.</p>
  774. </dd>
  775. <dt><strong>moments_central</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  776. <dd><dl class="first docutils">
  777. <dt>Central moments (translation invariant) up to 3rd order::</dt>
  778. <dd>mu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }</dd>
  779. </dl>
  780. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region,
  781. and <cite>x_c</cite> and <cite>y_c</cite> are the coordinates of the region’s centroid.</p>
  782. </dd>
  783. <dt><strong>moments_hu</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  784. <dd>Hu moments (translation, scale and rotation invariant).</dd>
  785. <dt><strong>moments_normalized</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  786. <dd><dl class="first docutils">
  787. <dt>Normalized moments (translation and scale invariant) up to 3rd order::</dt>
  788. <dd>nu_ji = mu_ji / m_00^[(i+j)/2 + 1]</dd>
  789. </dl>
  790. <p class="last">where <cite>m_00</cite> is the zeroth spatial moment.</p>
  791. </dd>
  792. <dt><strong>orientation</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  793. <dd>Angle between the X-axis and the major axis of the ellipse that has
  794. the same second-moments as the region. Ranging from <cite>-pi/2</cite> to
  795. <cite>pi/2</cite> in counter-clockwise direction.</dd>
  796. <dt><strong>perimeter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  797. <dd>Perimeter of object which approximates the contour as a line
  798. through the centers of border pixels using a 4-connectivity.</dd>
  799. <dt><strong>solidity</strong> <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  800. <dd>Ratio of pixels in the region to pixels of the convex hull image.</dd>
  801. <dt><strong>weighted_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  802. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code> weighted with intensity
  803. image.</dd>
  804. <dt><strong>weighted_local_centroid</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array</span></dt>
  805. <dd>Centroid coordinate tuple <code class="docutils literal"><span class="pre">(row,</span> <span class="pre">col)</span></code>, relative to region bounding
  806. box, weighted with intensity image.</dd>
  807. <dt><strong>weighted_moments</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  808. <dd><dl class="first docutils">
  809. <dt>Spatial moments of intensity image up to 3rd order::</dt>
  810. <dd>wm_ji = sum{ array(x, y) * x^j * y^i }</dd>
  811. </dl>
  812. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region.</p>
  813. </dd>
  814. <dt><strong>weighted_moments_central</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  815. <dd><p class="first">Central moments (translation invariant) of intensity image up to
  816. 3rd order:</p>
  817. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wmu_ji</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">{</span> <span class="n">array</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">x_c</span><span class="p">)</span><span class="o">^</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">y</span> <span class="o">-</span> <span class="n">y_c</span><span class="p">)</span><span class="o">^</span><span class="n">i</span> <span class="p">}</span>
  818. </pre></div>
  819. </div>
  820. <p class="last">where the sum is over the <cite>x</cite>, <cite>y</cite> coordinates of the region,
  821. and <cite>x_c</cite> and <cite>y_c</cite> are the coordinates of the region’s weighted
  822. centroid.</p>
  823. </dd>
  824. <dt><strong>weighted_moments_hu</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt>
  825. <dd>Hu moments (translation, scale and rotation invariant) of intensity
  826. image.</dd>
  827. <dt><strong>weighted_moments_normalized</strong> <span class="classifier-delimiter">:</span> <span class="classifier">(3, 3) ndarray</span></dt>
  828. <dd><p class="first">Normalized moments (translation and scale invariant) of intensity
  829. image up to 3rd order:</p>
  830. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wnu_ji</span> <span class="o">=</span> <span class="n">wmu_ji</span> <span class="o">/</span> <span class="n">wm_00</span><span class="o">^</span><span class="p">[(</span><span class="n">i</span><span class="o">+</span><span class="n">j</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
  831. </pre></div>
  832. </div>
  833. <p class="last">where <code class="docutils literal"><span class="pre">wm_00</span></code> is the zeroth spatial moment (intensity-weighted area).</p>
  834. </dd>
  835. </dl>
  836. </dd></dl>
  837. </dd></dl>
  838. </div>
  839. <div class="section" id="module-Features">
  840. <span id="features"></span><h2>Features<a class="headerlink" href="#module-Features" title="Permalink to this headline">¶</a></h2>
  841. <dl class="class">
  842. <dt id="Features.Features">
  843. <em class="property">class </em><code class="descclassname">Features.</code><code class="descname">Features</code><span class="sig-paren">(</span><em>data_frame</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features" title="Permalink to this definition">¶</a></dt>
  844. <dd><p>contain the dataframe</p>
  845. <dl class="method">
  846. <dt id="Features.Features.get_class_name">
  847. <code class="descname">get_class_name</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.get_class_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.get_class_name" title="Permalink to this definition">¶</a></dt>
  848. <dd></dd></dl>
  849. <dl class="method">
  850. <dt id="Features.Features.get_class_value">
  851. <code class="descname">get_class_value</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.get_class_value"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.get_class_value" title="Permalink to this definition">¶</a></dt>
  852. <dd></dd></dl>
  853. <dl class="method">
  854. <dt id="Features.Features.get_dataframe">
  855. <code class="descname">get_dataframe</code><span class="sig-paren">(</span><em>include_class=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.get_dataframe"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.get_dataframe" title="Permalink to this definition">¶</a></dt>
  856. <dd><p>creates a panda data frame contining the feature values</p>
  857. <table class="docutils field-list" frame="void" rules="none">
  858. <col class="field-name" />
  859. <col class="field-body" />
  860. <tbody valign="top">
  861. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>include_class</strong> (<em>Boolean</em>) – if True if includes the class name and value as the last column</td>
  862. </tr>
  863. </tbody>
  864. </table>
  865. </dd></dl>
  866. <dl class="method">
  867. <dt id="Features.Features.merge">
  868. <code class="descname">merge</code><span class="sig-paren">(</span><em>Features_Obj</em>, <em>how_in='inner'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.merge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.merge" title="Permalink to this definition">¶</a></dt>
  869. <dd><p>Merges in the current Features object a second Features object (ex. obtained from the Voronoi Object)</p>
  870. <table class="docutils field-list" frame="void" rules="none">
  871. <col class="field-name" />
  872. <col class="field-body" />
  873. <tbody valign="top">
  874. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  875. <li><strong>Features_Obj</strong> (<a class="reference internal" href="#module-Features" title="Features"><em>Features</em></a><em> (</em><em>image_features_extraction package</em><em>)</em>) – External Features Object</li>
  876. <li><strong>how_in</strong> (<em>string</em>) – ‘inner’, ‘outer’</li>
  877. </ul>
  878. </td>
  879. </tr>
  880. </tbody>
  881. </table>
  882. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction.Images</span> <span class="k">as</span> <span class="nn">fe</span>
  883. <span class="gp">&gt;&gt;&gt; </span><span class="n">IMGS</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="s1">&#39;../images/CA/1&#39;</span><span class="p">)</span>
  884. <span class="gp">&gt;&gt;&gt; </span><span class="n">vor</span> <span class="o">=</span> <span class="n">IMG</span><span class="o">.</span><span class="n">Voronoi</span><span class="p">()</span>
  885. <span class="gp">&gt;&gt;&gt; </span><span class="n">features1</span> <span class="o">=</span> <span class="n">IMG</span><span class="o">.</span><span class="n">features</span><span class="p">([</span><span class="s1">&#39;area&#39;</span><span class="p">,</span><span class="s1">&#39;perimeter&#39;</span><span class="p">,</span><span class="s1">&#39;centroid&#39;</span><span class="p">,</span><span class="s1">&#39;bbox&#39;</span><span class="p">,</span> <span class="s1">&#39;eccentricity&#39;</span><span class="p">])</span>
  886. <span class="gp">&gt;&gt;&gt; </span><span class="n">features2</span> <span class="o">=</span> <span class="n">vor</span><span class="o">.</span><span class="n">features</span><span class="p">([</span><span class="s1">&#39;area&#39;</span><span class="p">,</span><span class="s1">&#39;perimeter&#39;</span><span class="p">,</span><span class="s1">&#39;centroid&#39;</span><span class="p">,</span><span class="s1">&#39;bbox&#39;</span><span class="p">,</span> <span class="s1">&#39;eccentricity&#39;</span><span class="p">])</span>
  887. <span class="gp">&gt;&gt;&gt; </span><span class="n">features3</span> <span class="o">=</span> <span class="n">features1</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">features2</span><span class="p">,</span> <span class="n">how_in</span><span class="o">=</span><span class="s1">&#39;inner&#39;</span><span class="p">)</span>
  888. <span class="gp">&gt;&gt;&gt; </span><span class="n">features3</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">()</span><span class="o">.</span><span class="n">head</span><span class="p">()</span>
  889. </pre></div>
  890. </div>
  891. </dd></dl>
  892. <dl class="method">
  893. <dt id="Features.Features.save">
  894. <code class="descname">save</code><span class="sig-paren">(</span><em>storage_name</em>, <em>type_storage='file'</em>, <em>do_append=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.save"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.save" title="Permalink to this definition">¶</a></dt>
  895. <dd><p>save the current dataframe into the type of storage given in input.</p>
  896. <table class="docutils field-list" frame="void" rules="none">
  897. <col class="field-name" />
  898. <col class="field-body" />
  899. <tbody valign="top">
  900. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  901. <li><strong>storage_name</strong> (<em>string</em>) – storage name, (e.g., file name if ‘ storage type is ‘file’)</li>
  902. <li><strong>type_storage</strong> (<em>string</em>) – type of storage (default is ‘file’) (‘db’, ‘json’ will be future implementations)</li>
  903. <li><strong>do_append</strong> (<em>boolean</em>) – if True it appends to existing storage. If False it creates a new storage</li>
  904. </ul>
  905. </td>
  906. </tr>
  907. </tbody>
  908. </table>
  909. <p>if ‘do_append=True’: This version of the method does not check whether the new data are consistent with presisitng data into
  910. the existing storage. It just tries to append the date and might fail or not depending on the type of storage</p>
  911. <table class="docutils field-list" frame="void" rules="none">
  912. <col class="field-name" />
  913. <col class="field-body" />
  914. <tbody valign="top">
  915. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">1 if sucessuful otherwise 0</td>
  916. </tr>
  917. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td>
  918. </tr>
  919. <tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td>
  920. </tr>
  921. </tbody>
  922. </table>
  923. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">image_features_extraction</span> <span class="k">as</span> <span class="nn">fe</span>
  924. <span class="gp">&gt;&gt;&gt; </span><span class="n">imgs</span> <span class="o">=</span> <span class="n">fe</span><span class="o">.</span><span class="n">Images</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
  925. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">imgs</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  926. <span class="gp">&gt;&gt;&gt; </span><span class="n">reg</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">Regions</span><span class="p">()</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
  927. <span class="gp">&gt;&gt;&gt; </span><span class="n">features</span> <span class="o">=</span> <span class="n">regs</span><span class="o">.</span><span class="n">get_features</span><span class="p">([</span><span class="s1">&#39;label&#39;</span><span class="p">,</span> <span class="s1">&#39;area&#39;</span><span class="p">,</span><span class="s1">&#39;perimeter&#39;</span><span class="p">,</span> <span class="s1">&#39;centroid&#39;</span><span class="p">],</span> <span class="n">class_value</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
  928. <span class="gp">&gt;&gt;&gt; </span><span class="n">features</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="s1">&#39;my_file_name&#39;</span><span class="p">)</span>
  929. </pre></div>
  930. </div>
  931. </dd></dl>
  932. <dl class="method">
  933. <dt id="Features.Features.set_class_name">
  934. <code class="descname">set_class_name</code><span class="sig-paren">(</span><em>class_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.set_class_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.set_class_name" title="Permalink to this definition">¶</a></dt>
  935. <dd></dd></dl>
  936. <dl class="method">
  937. <dt id="Features.Features.set_class_value">
  938. <code class="descname">set_class_value</code><span class="sig-paren">(</span><em>class_value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Features.html#Features.set_class_value"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Features.Features.set_class_value" title="Permalink to this definition">¶</a></dt>
  939. <dd></dd></dl>
  940. </dd></dl>
  941. </div>
  942. </div>
  943. </div>
  944. </div>
  945. </div>
  946. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  947. <div class="sphinxsidebarwrapper">
  948. <h1 class="logo"><a href="index.html">Image Features Extraction</a></h1>
  949. <h3>Navigation</h3>
  950. <ul class="current">
  951. <li class="toctree-l1"><a class="reference internal" href="tutorial.html">Tutorial</a></li>
  952. <li class="toctree-l1 current"><a class="current reference internal" href="#">Classes/Modules</a><ul>
  953. <li class="toctree-l2"><a class="reference internal" href="#module-Images">Images</a></li>
  954. <li class="toctree-l2"><a class="reference internal" href="#module-Image">Image</a></li>
  955. <li class="toctree-l2"><a class="reference internal" href="#module-Regions">Regions</a></li>
  956. <li class="toctree-l2"><a class="reference internal" href="#module-Region">Region</a></li>
  957. <li class="toctree-l2"><a class="reference internal" href="#module-Features">Features</a></li>
  958. </ul>
  959. </li>
  960. </ul>
  961. <div class="relations">
  962. <h3>Related Topics</h3>
  963. <ul>
  964. <li><a href="index.html">Documentation overview</a><ul>
  965. <li>Previous: <a href="tutorial.html" title="previous chapter">Tutorial</a></li>
  966. </ul></li>
  967. </ul>
  968. </div>
  969. <div id="searchbox" style="display: none" role="search">
  970. <h3>Quick search</h3>
  971. <form class="search" action="search.html" method="get">
  972. <div><input type="text" name="q" /></div>
  973. <div><input type="submit" value="Go" /></div>
  974. <input type="hidden" name="check_keywords" value="yes" />
  975. <input type="hidden" name="area" value="default" />
  976. </form>
  977. </div>
  978. <script type="text/javascript">$('#searchbox').show(0);</script>
  979. </div>
  980. </div>
  981. <div class="clearer"></div>
  982. </div>
  983. <div class="footer">
  984. &copy;2017, Remigio Picone.
  985. |
  986. Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.3</a>
  987. &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
  988. |
  989. <a href="_sources/code.rst.txt"
  990. rel="nofollow">Page source</a>
  991. </div>
  992. </body>
  993. </html>