<!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/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.14"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>tesseract: classify/intfeaturemap.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(initResizable); /* @license-end */</script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">tesseract  <span id="projectnumber">3.05.02</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.14 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ var searchBox = new SearchBox("searchBox", "search",false,'Search'); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('a00713_source.html','');}); /* @license-end */ </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="headertitle"> <div class="title">intfeaturemap.cpp</div> </div> </div><!--header--> <div class="contents"> <a href="a00713.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Copyright 2010 Google Inc. All Rights Reserved.</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">// Author: rays@google.com (Ray Smith)</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"></span><span class="comment">// File: intfeaturemap.cpp</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment">// Description: Encapsulation of IntFeatureSpace with IndexMapBiDi</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment">// to provide a subspace mapping and fast feature lookup.</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">// Created: Tue Oct 26 08:58:30 PDT 2010</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">//</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// you may not use this file except in compliance with the License.</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// You may obtain a copy of the License at</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment">// Unless required by applicable law or agreed to in writing, software</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment">// See the License for the specific language governing permissions and</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">// limitations under the License.</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment">//</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment"></span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include "<a class="code" href="a00716.html">intfeaturemap.h</a>"</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include "<a class="code" href="a00722.html">intfeaturespace.h</a>"</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include "<a class="code" href="a00728.html">intfx.h</a>"</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="comment">// These includes do not exist yet, but will be coming soon.</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="comment">//#include "sampleiterator.h"</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="comment">//#include "trainingsample.h"</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="comment">//#include "trainingsampleset.h"</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> </div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">namespace </span><a class="code" href="a01738.html">tesseract</a> {</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div><div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="a01738.html#a5ed5ea7e3054219b18144501c5ec3d1e"> 32</a></span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="a01738.html#a5ed5ea7e3054219b18144501c5ec3d1e">kMaxOffsetDist</a> = 32;</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> </div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="a04161.html#a3fbd4062c08d2b3234e43b6fb8278bca"> 34</a></span> <a class="code" href="a04161.html#a3fbd4062c08d2b3234e43b6fb8278bca">IntFeatureMap::IntFeatureMap</a>()</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  : mapping_changed_(true), compact_size_(0) {</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> dir = 0; dir < kNumOffsetMaps; ++dir) {</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  offset_plus_[dir] = NULL;</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  offset_minus_[dir] = NULL;</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  }</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> }</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> </div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="a04161.html#ae7cf24a11435b7ebabbaa21f55d14325"> 42</a></span> <a class="code" href="a04161.html#ae7cf24a11435b7ebabbaa21f55d14325">IntFeatureMap::~IntFeatureMap</a>() {</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  Clear();</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> }</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> </div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="comment">// Pseudo-accessors.</span></div><div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="a04161.html#ae4b44cef1375d042b004687fbe70d77c"> 47</a></span> <span class="keywordtype">int</span> <a class="code" href="a04161.html#ae4b44cef1375d042b004687fbe70d77c">IntFeatureMap::IndexFeature</a>(<span class="keyword">const</span> <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a>& f)<span class="keyword"> const </span>{</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="keywordflow">return</span> feature_space_.<a class="code" href="a04165.html#aa01d306fc0433b1d780d03aabc3a09c2">Index</a>(f);</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span> }</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="a04161.html#a1f05545a0668ea68c8609a5de4068e43"> 50</a></span> <span class="keywordtype">int</span> <a class="code" href="a04161.html#a1f05545a0668ea68c8609a5de4068e43">IntFeatureMap::MapFeature</a>(<span class="keyword">const</span> <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a>& f)<span class="keyword"> const </span>{</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="keywordflow">return</span> feature_map_.<a class="code" href="a02837.html#ac5903703a1abfbea788b2d2c55bf2db5">SparseToCompact</a>(feature_space_.<a class="code" href="a04165.html#aa01d306fc0433b1d780d03aabc3a09c2">Index</a>(f));</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span> }</div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="a04161.html#a928226c96da1c84d530b31540dd76fc2"> 53</a></span> <span class="keywordtype">int</span> <a class="code" href="a04161.html#a928226c96da1c84d530b31540dd76fc2">IntFeatureMap::MapIndexFeature</a>(<span class="keywordtype">int</span> index_feature)<span class="keyword"> const </span>{</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keywordflow">return</span> feature_map_.<a class="code" href="a02837.html#ac5903703a1abfbea788b2d2c55bf2db5">SparseToCompact</a>(index_feature);</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span> }</div><div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="a04161.html#a5e383045fdab001db353ec1621475389"> 56</a></span> <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a> <a class="code" href="a04161.html#a5e383045fdab001db353ec1621475389">IntFeatureMap::InverseIndexFeature</a>(<span class="keywordtype">int</span> index_feature)<span class="keyword"> const </span>{</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keywordflow">return</span> feature_space_.<a class="code" href="a04165.html#a89de22c1c2aef24cae668aa656790161">PositionFromIndex</a>(index_feature);</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> }</div><div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="a04161.html#a7e0fa3cbffb621cb594e9868436558bb"> 59</a></span> <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a> <a class="code" href="a04161.html#a7e0fa3cbffb621cb594e9868436558bb">IntFeatureMap::InverseMapFeature</a>(<span class="keywordtype">int</span> map_feature)<span class="keyword"> const </span>{</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="keywordtype">int</span> index = feature_map_.<a class="code" href="a02833.html#af62a866b7d77b90b0bee192ae7ee3fd3">CompactToSparse</a>(map_feature);</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <span class="keywordflow">return</span> feature_space_.<a class="code" href="a04165.html#a89de22c1c2aef24cae668aa656790161">PositionFromIndex</a>(index);</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> }</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="a04161.html#a9f520c6a69fa114d9eff812d936063a2"> 63</a></span> <span class="keywordtype">void</span> <a class="code" href="a04161.html#a9f520c6a69fa114d9eff812d936063a2">IntFeatureMap::DeleteMapFeature</a>(<span class="keywordtype">int</span> map_feature) {</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  feature_map_.<a class="code" href="a02837.html#a2065aea120b8bbad4afc135bc3473044">Merge</a>(-1, map_feature);</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  mapping_changed_ = <span class="keyword">true</span>;</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span> }</div><div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="a04161.html#a7de7f2bf8909c857c2851112418fdc35"> 67</a></span> <span class="keywordtype">bool</span> <a class="code" href="a04161.html#a7de7f2bf8909c857c2851112418fdc35">IntFeatureMap::IsMapFeatureDeleted</a>(<span class="keywordtype">int</span> map_feature)<span class="keyword"> const </span>{</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  <span class="keywordflow">return</span> feature_map_.<a class="code" href="a02837.html#af016a084e6113d66cc0a7b18b3d7fb61">IsCompactDeleted</a>(map_feature);</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> }</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> </div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="comment">// Copies the given feature_space and uses it as the index feature map</span></div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> <span class="comment">// from INT_FEATURE_STRUCT.</span></div><div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="a04161.html#aa2a41837ff48a80829cf8c7d5ca4917d"> 73</a></span> <span class="keywordtype">void</span> <a class="code" href="a04161.html#aa2a41837ff48a80829cf8c7d5ca4917d">IntFeatureMap::Init</a>(<span class="keyword">const</span> <a class="code" href="a04165.html">IntFeatureSpace</a>& feature_space) {</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  feature_space_ = <a class="code" href="a04161.html#a53392ad639c38c2d71cbb8a844fbcb7e">feature_space</a>;</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  mapping_changed_ = <span class="keyword">false</span>;</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <span class="keywordtype">int</span> <a class="code" href="a04161.html#ad5a3176dde1840c3f132ae2f8fc3440e">sparse_size</a> = feature_space_.<a class="code" href="a04165.html#a12e52819b74507e1d76a79bac2d04968">Size</a>();</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  feature_map_.<a class="code" href="a02837.html#a165b8de5eeba0557d206f76b556793d9">Init</a>(<a class="code" href="a04161.html#ad5a3176dde1840c3f132ae2f8fc3440e">sparse_size</a>, <span class="keyword">true</span>);</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  feature_map_.<a class="code" href="a02837.html#a909e48dddc1488311f4d7083544eca56">Setup</a>();</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  compact_size_ = feature_map_.<a class="code" href="a02833.html#a33c1174b210b07024679d3c6f091c5b0">CompactSize</a>();</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="comment">// Initialize look-up tables if needed.</span></div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <a class="code" href="a02681.html">FCOORD</a> dir = <a class="code" href="a00725.html#a31bfe591242811378902d7342621a59b">FeatureDirection</a>(0);</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <span class="keywordflow">if</span> (dir.<a class="code" href="a02681.html#aecd85311c159bcd52b485a97a8dcc901">x</a>() == 0.0f && dir.<a class="code" href="a02681.html#abb9516f874133b689b0e62ac70874385">y</a>() == 0.0f)</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <a class="code" href="a00725.html#a1281b17b87e56c99d53fe6bb1f7c2d55">InitIntegerFX</a>();</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="comment">// Compute look-up tables to generate offset features.</span></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> dir = 0; dir < kNumOffsetMaps; ++dir) {</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="keyword">delete</span> [] offset_plus_[dir];</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="keyword">delete</span> [] offset_minus_[dir];</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  offset_plus_[dir] = <span class="keyword">new</span> <span class="keywordtype">int</span>[<a class="code" href="a04161.html#ad5a3176dde1840c3f132ae2f8fc3440e">sparse_size</a>];</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  offset_minus_[dir] = <span class="keyword">new</span> <span class="keywordtype">int</span>[<a class="code" href="a04161.html#ad5a3176dde1840c3f132ae2f8fc3440e">sparse_size</a>];</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  }</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> dir = 1; dir <= kNumOffsetMaps; ++dir) {</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < <a class="code" href="a04161.html#ad5a3176dde1840c3f132ae2f8fc3440e">sparse_size</a>; ++i) {</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="keywordtype">int</span> offset_index = ComputeOffsetFeature(i, dir);</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  offset_plus_[dir - 1][i] = offset_index;</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  offset_index = ComputeOffsetFeature(i, -dir);</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  offset_minus_[dir - 1][i] = offset_index;</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  }</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  }</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span> }</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span> </div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span> <span class="comment">// Helper to return an offset index feature. In this context an offset</span></div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span> <span class="comment">// feature with a dir of +/-1 is a feature of a similar direction,</span></div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span> <span class="comment">// but shifted perpendicular to the direction of the feature. An offset</span></div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span> <span class="comment">// feature with a dir of +/-2 is feature at the same position, but rotated</span></div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span> <span class="comment">// by +/- one [compact] quantum. Returns the index of the generated offset</span></div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span> <span class="comment">// feature, or -1 if it doesn't exist. Dir should be in</span></div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span> <span class="comment">// [-kNumOffsetMaps, kNumOffsetMaps] to indicate the relative direction.</span></div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span> <span class="comment">// A dir of 0 is an identity transformation.</span></div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span> <span class="comment">// Both input and output are from the index(sparse) feature space, not</span></div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span> <span class="comment">// the mapped/compact feature space, but the offset feature is the minimum</span></div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span> <span class="comment">// distance moved from the input to guarantee that it maps to the next</span></div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span> <span class="comment">// available quantum in the mapped/compact space.</span></div><div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="a04161.html#a9b4fdf30651a0e82cb852616f1f0fede"> 113</a></span> <span class="keywordtype">int</span> <a class="code" href="a04161.html#a9b4fdf30651a0e82cb852616f1f0fede">IntFeatureMap::OffsetFeature</a>(<span class="keywordtype">int</span> index_feature, <span class="keywordtype">int</span> dir)<span class="keyword"> const </span>{</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  <span class="keywordflow">if</span> (dir > 0 && dir <= kNumOffsetMaps)</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <span class="keywordflow">return</span> offset_plus_[dir - 1][index_feature];</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dir < 0 && -dir <= kNumOffsetMaps)</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="keywordflow">return</span> offset_minus_[-dir - 1][index_feature];</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dir == 0)</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <span class="keywordflow">return</span> index_feature;</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> }</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span> </div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span> </div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span> <span class="comment">//#define EXPERIMENT_ON</span></div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span> <span class="preprocessor">#ifdef EXPERIMENT_ON // This code is commented out as SampleIterator and</span></div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span> <span class="comment">// TrainingSample are not reviewed/checked in yet, but these functions are a</span></div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span> <span class="comment">// useful indicator of how an IntFeatureMap is setup.</span></div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span> </div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span> <span class="comment">// Computes the features used by the subset of samples defined by</span></div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span> <span class="comment">// the iterator and sets up the feature mapping.</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span> <span class="comment">// Returns the size of the compacted feature space.</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span> <span class="keywordtype">int</span> <a class="code" href="a04161.html#aa04a441902ce2cc53b225dc6487e6650">IntFeatureMap::FindNZFeatureMapping</a>(<a class="code" href="a04285.html">SampleIterator</a>* it) {</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  feature_map_.<a class="code" href="a02837.html#a165b8de5eeba0557d206f76b556793d9">Init</a>(feature_space_.<a class="code" href="a04165.html#a12e52819b74507e1d76a79bac2d04968">Size</a>(), <span class="keyword">false</span>);</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="keywordtype">int</span> total_samples = 0;</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keywordflow">for</span> (it-><a class="code" href="a04285.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>(); !it-><a class="code" href="a04285.html#a7e11e4b8e61d345913715b75cf3af7a4">AtEnd</a>(); it-><a class="code" href="a04285.html#aea58e8234a0b6bab9061929622150bb1">Next</a>()) {</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keyword">const</span> <a class="code" href="a04321.html">TrainingSample</a>& <a class="code" href="a04113.html">sample</a> = it-><a class="code" href="a04285.html#a0114b65ff7e6b109263aad3bd723e36c">GetSample</a>();</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <a class="code" href="a02297.html">GenericVector<int></a> features;</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  feature_space_.<a class="code" href="a04165.html#afc33368d7ee0424316faffb752602fbf">IndexAndSortFeatures</a>(<a class="code" href="a04113.html">sample</a>.features(),</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <a class="code" href="a04113.html">sample</a>.num_features(),</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  &features);</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="keywordtype">int</span> num_features = features.<a class="code" href="a02297.html#a20cfad5c58c50cb85a9529d8ddbd96af">size</a>();</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> f = 0; f < num_features; ++f)</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  feature_map_.<a class="code" href="a02837.html#a3b4579cc4934a996ea688de031e758f2">SetMap</a>(features[f], <span class="keyword">true</span>);</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  ++total_samples;</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  }</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  feature_map_.<a class="code" href="a02837.html#a909e48dddc1488311f4d7083544eca56">Setup</a>();</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  compact_size_ = feature_map_.<a class="code" href="a02833.html#a33c1174b210b07024679d3c6f091c5b0">CompactSize</a>();</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  mapping_changed_ = <span class="keyword">true</span>;</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <a class="code" href="a04161.html#af3348594a6926c20c0366e3acb56a4ef">FinalizeMapping</a>(it);</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">"%d non-zero features found in %d samples\n"</span>,</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  compact_size_, total_samples);</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="keywordflow">return</span> compact_size_;</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span> }</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span> </div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span> <span class="comment">// After deleting some features, finish setting up the mapping, and map</span></div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="comment">// all the samples. Returns the size of the compacted feature space.</span></div><div class="line"><a name="l00159"></a><span class="lineno"><a class="line" href="a04161.html#af3348594a6926c20c0366e3acb56a4ef"> 159</a></span> <span class="keywordtype">int</span> <a class="code" href="a04161.html#af3348594a6926c20c0366e3acb56a4ef">IntFeatureMap::FinalizeMapping</a>(<a class="code" href="a04285.html">SampleIterator</a>* it) {</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  <span class="keywordflow">if</span> (mapping_changed_) {</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  feature_map_.<a class="code" href="a02837.html#ab809f6fe92e0f3a7bce25eeb183ab120">CompleteMerges</a>();</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  compact_size_ = feature_map_.<a class="code" href="a02833.html#a33c1174b210b07024679d3c6f091c5b0">CompactSize</a>();</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span> <span class="preprocessor">#ifdef EXPERIMENT_ON</span></div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  it-><a class="code" href="a04285.html#a476d245234d73a6c9ef7c85b57148a27">MapSampleFeatures</a>(*<span class="keyword">this</span>);</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  mapping_changed_ = <span class="keyword">false</span>;</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  }</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  <span class="keywordflow">return</span> compact_size_;</div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span> }</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span> </div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span> <span class="comment">// Prints the map features from the set in human-readable form.</span></div><div class="line"><a name="l00172"></a><span class="lineno"><a class="line" href="a04161.html#a60501cd8fab8dc6f0d0e987da003b0b9"> 172</a></span> <span class="keywordtype">void</span> <a class="code" href="a04161.html#a60501cd8fab8dc6f0d0e987da003b0b9">IntFeatureMap::DebugMapFeatures</a>(</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  <span class="keyword">const</span> <a class="code" href="a02297.html">GenericVector<int></a>& map_features)<span class="keyword"> const </span>{</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < map_features.<a class="code" href="a02297.html#a20cfad5c58c50cb85a9529d8ddbd96af">size</a>(); ++i) {</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a> f = <a class="code" href="a04161.html#a7e0fa3cbffb621cb594e9868436558bb">InverseMapFeature</a>(map_features[i]);</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  f.<a class="code" href="a04221.html#a3df5da933e95b4d6c63586b63ee9a88b">print</a>();</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  }</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span> }</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span> </div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span> <span class="keywordtype">void</span> IntFeatureMap::Clear() {</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> dir = 0; dir < kNumOffsetMaps; ++dir) {</div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  <span class="keyword">delete</span> [] offset_plus_[dir];</div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  <span class="keyword">delete</span> [] offset_minus_[dir];</div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  offset_plus_[dir] = NULL;</div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  offset_minus_[dir] = NULL;</div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  }</div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span> }</div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span> </div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span> <span class="comment">// Helper to compute an offset index feature. In this context an offset</span></div><div class="line"><a name="l00190"></a><span class="lineno"> 190</span> <span class="comment">// feature with a dir of +/-1 is a feature of a similar direction,</span></div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span> <span class="comment">// but shifted perpendicular to the direction of the feature. An offset</span></div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span> <span class="comment">// feature with a dir of +/-2 is feature at the same position, but rotated</span></div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span> <span class="comment">// by +/- one [compact] quantum. Returns the index of the generated offset</span></div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span> <span class="comment">// feature, or -1 if it doesn't exist. Dir should be in</span></div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span> <span class="comment">// [-kNumOffsetMaps, kNumOffsetMaps] to indicate the relative direction.</span></div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span> <span class="comment">// A dir of 0 is an identity transformation.</span></div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span> <span class="comment">// Both input and output are from the index(sparse) feature space, not</span></div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span> <span class="comment">// the mapped/compact feature space, but the offset feature is the minimum</span></div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span> <span class="comment">// distance moved from the input to guarantee that it maps to the next</span></div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span> <span class="comment">// available quantum in the mapped/compact space.</span></div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span> <span class="keywordtype">int</span> IntFeatureMap::ComputeOffsetFeature(<span class="keywordtype">int</span> index_feature, <span class="keywordtype">int</span> dir)<span class="keyword"> const </span>{</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a> f = <a class="code" href="a04161.html#a5e383045fdab001db353ec1621475389">InverseIndexFeature</a>(index_feature);</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  <a class="code" href="a00500.html#a93a603f4063a6b9403d81caa245a583b">ASSERT_HOST</a>(<a class="code" href="a04161.html#ae4b44cef1375d042b004687fbe70d77c">IndexFeature</a>(f) == index_feature);</div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  <span class="keywordflow">if</span> (dir == 0) {</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  <span class="keywordflow">return</span> index_feature;</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dir == 1 || dir == -1) {</div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  <a class="code" href="a02681.html">FCOORD</a> feature_dir = <a class="code" href="a00725.html#a31bfe591242811378902d7342621a59b">FeatureDirection</a>(f.<a class="code" href="a04221.html#af4a2ea6a7d9a82cba06f6ca9a126461b">Theta</a>);</div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  <a class="code" href="a02681.html">FCOORD</a> rotation90(0.0f, 1.0f);</div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  feature_dir.<a class="code" href="a02681.html#a81ca9ea0cac4cd8c1bca0314e29bb28d">rotate</a>(rotation90);</div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="comment">// Find the nearest existing feature.</span></div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> m = 1; m < <a class="code" href="a01738.html#a5ed5ea7e3054219b18144501c5ec3d1e">kMaxOffsetDist</a>; ++m) {</div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  <span class="keywordtype">double</span> x_pos = f.<a class="code" href="a04221.html#a6b250df12a9b06b5ed0c1a7c403f0275">X</a> + feature_dir.<a class="code" href="a02681.html#aecd85311c159bcd52b485a97a8dcc901">x</a>() * (m * dir);</div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  <span class="keywordtype">double</span> y_pos = f.<a class="code" href="a04221.html#a09931683890fb52d22ec6c75048a2bce">Y</a> + feature_dir.<a class="code" href="a02681.html#abb9516f874133b689b0e62ac70874385">y</a>() * (m * dir);</div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span>  <span class="keywordtype">int</span> x = <a class="code" href="a00521.html#ab60e4f82956a1f5fdb54d0d8303e95b7">IntCastRounded</a>(x_pos);</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  <span class="keywordtype">int</span> y = <a class="code" href="a00521.html#ab60e4f82956a1f5fdb54d0d8303e95b7">IntCastRounded</a>(y_pos);</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  <span class="keywordflow">if</span> (x >= 0 && x <= MAX_UINT8 && y >= 0 && y <= <a class="code" href="a00524.html#a05682ca8de174141447ff05a2289a27c">MAX_UINT8</a>) {</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a> offset_f;</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  offset_f.<a class="code" href="a04221.html#a6b250df12a9b06b5ed0c1a7c403f0275">X</a> = x;</div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  offset_f.<a class="code" href="a04221.html#a09931683890fb52d22ec6c75048a2bce">Y</a> = y;</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  offset_f.<a class="code" href="a04221.html#af4a2ea6a7d9a82cba06f6ca9a126461b">Theta</a> = f.<a class="code" href="a04221.html#af4a2ea6a7d9a82cba06f6ca9a126461b">Theta</a>;</div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  <span class="keywordtype">int</span> offset_index = <a class="code" href="a04161.html#ae4b44cef1375d042b004687fbe70d77c">IndexFeature</a>(offset_f);</div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  <span class="keywordflow">if</span> (offset_index != index_feature && offset_index >= 0)</div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  <span class="keywordflow">return</span> offset_index; <span class="comment">// Found one.</span></div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>  <span class="keywordflow">return</span> -1; <span class="comment">// Hit the edge of feature space.</span></div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>  }</div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  }</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dir == 2 || dir == -2) {</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  <span class="comment">// Find the nearest existing index_feature.</span></div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> m = 1; m < <a class="code" href="a01738.html#a5ed5ea7e3054219b18144501c5ec3d1e">kMaxOffsetDist</a>; ++m) {</div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  <span class="keywordtype">int</span> theta = f.<a class="code" href="a04221.html#af4a2ea6a7d9a82cba06f6ca9a126461b">Theta</a> + m * dir / 2;</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  <a class="code" href="a04221.html">INT_FEATURE_STRUCT</a> offset_f;</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  offset_f.<a class="code" href="a04221.html#a6b250df12a9b06b5ed0c1a7c403f0275">X</a> = f.<a class="code" href="a04221.html#a6b250df12a9b06b5ed0c1a7c403f0275">X</a>;</div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  offset_f.<a class="code" href="a04221.html#a09931683890fb52d22ec6c75048a2bce">Y</a> = f.<a class="code" href="a04221.html#a09931683890fb52d22ec6c75048a2bce">Y</a>;</div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  offset_f.<a class="code" href="a04221.html#af4a2ea6a7d9a82cba06f6ca9a126461b">Theta</a> = <a class="code" href="a00521.html#a560c3ba94fe224dd67b10bd4cb5a6886">Modulo</a>(theta, 256);</div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  <span class="keywordtype">int</span> offset_index = <a class="code" href="a04161.html#ae4b44cef1375d042b004687fbe70d77c">IndexFeature</a>(offset_f);</div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span>  <span class="keywordflow">if</span> (offset_index != index_feature && offset_index >= 0)</div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  <span class="keywordflow">return</span> offset_index; <span class="comment">// Found one.</span></div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  }</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  }</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  <span class="keywordflow">return</span> -1; <span class="comment">// Nothing within the max distance.</span></div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span> }</div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span> </div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span> } <span class="comment">// namespace tesseract.</span></div><div class="ttc" id="a00722_html"><div class="ttname"><a href="a00722.html">intfeaturespace.h</a></div></div> <div class="ttc" id="a04285_html"><div class="ttname"><a href="a04285.html">tesseract::SampleIterator</a></div><div class="ttdef"><b>Definition:</b> <a href="a00818_source.html#l00092">sampleiterator.h:92</a></div></div> <div class="ttc" id="a04221_html_a09931683890fb52d22ec6c75048a2bce"><div class="ttname"><a href="a04221.html#a09931683890fb52d22ec6c75048a2bce">INT_FEATURE_STRUCT::Y</a></div><div class="ttdeci">uinT8 Y</div><div class="ttdef"><b>Definition:</b> <a href="a00740_source.html#l00144">intproto.h:144</a></div></div> <div class="ttc" id="a04161_html_ad5a3176dde1840c3f132ae2f8fc3440e"><div class="ttname"><a href="a04161.html#ad5a3176dde1840c3f132ae2f8fc3440e">tesseract::IntFeatureMap::sparse_size</a></div><div class="ttdeci">int sparse_size() const</div><div class="ttdef"><b>Definition:</b> <a href="a00716_source.html#l00054">intfeaturemap.h:54</a></div></div> <div class="ttc" id="a02297_html"><div class="ttname"><a href="a02297.html">GenericVector< int ></a></div></div> <div class="ttc" id="a00521_html_ab60e4f82956a1f5fdb54d0d8303e95b7"><div class="ttname"><a href="a00521.html#ab60e4f82956a1f5fdb54d0d8303e95b7">IntCastRounded</a></div><div class="ttdeci">int IntCastRounded(double x)</div><div class="ttdef"><b>Definition:</b> <a href="a00521_source.html#l00172">helpers.h:172</a></div></div> <div class="ttc" id="a02833_html_af62a866b7d77b90b0bee192ae7ee3fd3"><div class="ttname"><a href="a02833.html#af62a866b7d77b90b0bee192ae7ee3fd3">tesseract::IndexMap::CompactToSparse</a></div><div class="ttdeci">int CompactToSparse(int compact_index) const</div><div class="ttdef"><b>Definition:</b> <a href="a00530_source.html#l00053">indexmapbidi.h:53</a></div></div> <div class="ttc" id="a02837_html_ac5903703a1abfbea788b2d2c55bf2db5"><div class="ttname"><a href="a02837.html#ac5903703a1abfbea788b2d2c55bf2db5">tesseract::IndexMapBiDi::SparseToCompact</a></div><div class="ttdeci">virtual int SparseToCompact(int sparse_index) const</div><div class="ttdef"><b>Definition:</b> <a href="a00530_source.html#l00138">indexmapbidi.h:138</a></div></div> <div class="ttc" id="a04285_html_a476d245234d73a6c9ef7c85b57148a27"><div class="ttname"><a href="a04285.html#a476d245234d73a6c9ef7c85b57148a27">tesseract::SampleIterator::MapSampleFeatures</a></div><div class="ttdeci">void MapSampleFeatures(const IntFeatureMap &feature_map)</div><div class="ttdef"><b>Definition:</b> <a href="a00815_source.html#l00211">sampleiterator.cpp:211</a></div></div> <div class="ttc" id="a04285_html_a0114b65ff7e6b109263aad3bd723e36c"><div class="ttname"><a href="a04285.html#a0114b65ff7e6b109263aad3bd723e36c">tesseract::SampleIterator::GetSample</a></div><div class="ttdeci">const TrainingSample & GetSample() const</div><div class="ttdef"><b>Definition:</b> <a href="a00815_source.html#l00103">sampleiterator.cpp:103</a></div></div> <div class="ttc" id="a04285_html_a7e11e4b8e61d345913715b75cf3af7a4"><div class="ttname"><a href="a04285.html#a7e11e4b8e61d345913715b75cf3af7a4">tesseract::SampleIterator::AtEnd</a></div><div class="ttdeci">bool AtEnd() const</div><div class="ttdef"><b>Definition:</b> <a href="a00815_source.html#l00099">sampleiterator.cpp:99</a></div></div> <div class="ttc" id="a04161_html_af3348594a6926c20c0366e3acb56a4ef"><div class="ttname"><a href="a04161.html#af3348594a6926c20c0366e3acb56a4ef">tesseract::IntFeatureMap::FinalizeMapping</a></div><div class="ttdeci">int FinalizeMapping(SampleIterator *it)</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00159">intfeaturemap.cpp:159</a></div></div> <div class="ttc" id="a04161_html_ae7cf24a11435b7ebabbaa21f55d14325"><div class="ttname"><a href="a04161.html#ae7cf24a11435b7ebabbaa21f55d14325">tesseract::IntFeatureMap::~IntFeatureMap</a></div><div class="ttdeci">~IntFeatureMap()</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00042">intfeaturemap.cpp:42</a></div></div> <div class="ttc" id="a04161_html_a7de7f2bf8909c857c2851112418fdc35"><div class="ttname"><a href="a04161.html#a7de7f2bf8909c857c2851112418fdc35">tesseract::IntFeatureMap::IsMapFeatureDeleted</a></div><div class="ttdeci">bool IsMapFeatureDeleted(int map_feature) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00067">intfeaturemap.cpp:67</a></div></div> <div class="ttc" id="a04161_html_a60501cd8fab8dc6f0d0e987da003b0b9"><div class="ttname"><a href="a04161.html#a60501cd8fab8dc6f0d0e987da003b0b9">tesseract::IntFeatureMap::DebugMapFeatures</a></div><div class="ttdeci">void DebugMapFeatures(const GenericVector< int > &map_features) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00172">intfeaturemap.cpp:172</a></div></div> <div class="ttc" id="a04161_html_a7e0fa3cbffb621cb594e9868436558bb"><div class="ttname"><a href="a04161.html#a7e0fa3cbffb621cb594e9868436558bb">tesseract::IntFeatureMap::InverseMapFeature</a></div><div class="ttdeci">INT_FEATURE_STRUCT InverseMapFeature(int map_feature) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00059">intfeaturemap.cpp:59</a></div></div> <div class="ttc" id="a04321_html"><div class="ttname"><a href="a04321.html">tesseract::TrainingSample</a></div><div class="ttdef"><b>Definition:</b> <a href="a00842_source.html#l00053">trainingsample.h:53</a></div></div> <div class="ttc" id="a04221_html"><div class="ttname"><a href="a04221.html">INT_FEATURE_STRUCT</a></div><div class="ttdef"><b>Definition:</b> <a href="a00740_source.html#l00135">intproto.h:135</a></div></div> <div class="ttc" id="a04165_html_a12e52819b74507e1d76a79bac2d04968"><div class="ttname"><a href="a04165.html#a12e52819b74507e1d76a79bac2d04968">tesseract::IntFeatureSpace::Size</a></div><div class="ttdeci">int Size() const</div><div class="ttdef"><b>Definition:</b> <a href="a00722_source.html#l00056">intfeaturespace.h:56</a></div></div> <div class="ttc" id="a04221_html_a3df5da933e95b4d6c63586b63ee9a88b"><div class="ttname"><a href="a04221.html#a3df5da933e95b4d6c63586b63ee9a88b">INT_FEATURE_STRUCT::print</a></div><div class="ttdeci">void print() const</div><div class="ttdef"><b>Definition:</b> <a href="a00740_source.html#l00148">intproto.h:148</a></div></div> <div class="ttc" id="a04161_html_ae4b44cef1375d042b004687fbe70d77c"><div class="ttname"><a href="a04161.html#ae4b44cef1375d042b004687fbe70d77c">tesseract::IntFeatureMap::IndexFeature</a></div><div class="ttdeci">int IndexFeature(const INT_FEATURE_STRUCT &f) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00047">intfeaturemap.cpp:47</a></div></div> <div class="ttc" id="a04285_html_a90e5190efbff41c67519ba29fa59186f"><div class="ttname"><a href="a04285.html#a90e5190efbff41c67519ba29fa59186f">tesseract::SampleIterator::Begin</a></div><div class="ttdeci">void Begin()</div><div class="ttdef"><b>Definition:</b> <a href="a00815_source.html#l00087">sampleiterator.cpp:87</a></div></div> <div class="ttc" id="a00524_html_a05682ca8de174141447ff05a2289a27c"><div class="ttname"><a href="a00524.html#a05682ca8de174141447ff05a2289a27c">MAX_UINT8</a></div><div class="ttdeci">#define MAX_UINT8</div><div class="ttdef"><b>Definition:</b> <a href="a00524_source.html#l00054">host.h:54</a></div></div> <div class="ttc" id="a02681_html_a81ca9ea0cac4cd8c1bca0314e29bb28d"><div class="ttname"><a href="a02681.html#a81ca9ea0cac4cd8c1bca0314e29bb28d">FCOORD::rotate</a></div><div class="ttdeci">void rotate(const FCOORD vec)</div><div class="ttdef"><b>Definition:</b> <a href="a00284_source.html#l00471">ipoints.h:471</a></div></div> <div class="ttc" id="a04161_html_a1f05545a0668ea68c8609a5de4068e43"><div class="ttname"><a href="a04161.html#a1f05545a0668ea68c8609a5de4068e43">tesseract::IntFeatureMap::MapFeature</a></div><div class="ttdeci">int MapFeature(const INT_FEATURE_STRUCT &f) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00050">intfeaturemap.cpp:50</a></div></div> <div class="ttc" id="a01738_html_a5ed5ea7e3054219b18144501c5ec3d1e"><div class="ttname"><a href="a01738.html#a5ed5ea7e3054219b18144501c5ec3d1e">tesseract::kMaxOffsetDist</a></div><div class="ttdeci">const int kMaxOffsetDist</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00032">intfeaturemap.cpp:32</a></div></div> <div class="ttc" id="a04161_html_a53392ad639c38c2d71cbb8a844fbcb7e"><div class="ttname"><a href="a04161.html#a53392ad639c38c2d71cbb8a844fbcb7e">tesseract::IntFeatureMap::feature_space</a></div><div class="ttdeci">const IntFeatureSpace & feature_space() const</div><div class="ttdef"><b>Definition:</b> <a href="a00716_source.html#l00060">intfeaturemap.h:60</a></div></div> <div class="ttc" id="a02837_html_a2065aea120b8bbad4afc135bc3473044"><div class="ttname"><a href="a02837.html#a2065aea120b8bbad4afc135bc3473044">tesseract::IndexMapBiDi::Merge</a></div><div class="ttdeci">bool Merge(int compact_index1, int compact_index2)</div><div class="ttdef"><b>Definition:</b> <a href="a00527_source.html#l00121">indexmapbidi.cpp:121</a></div></div> <div class="ttc" id="a04161_html_aa04a441902ce2cc53b225dc6487e6650"><div class="ttname"><a href="a04161.html#aa04a441902ce2cc53b225dc6487e6650">tesseract::IntFeatureMap::FindNZFeatureMapping</a></div><div class="ttdeci">int FindNZFeatureMapping(SampleIterator *it)</div></div> <div class="ttc" id="a01738_html"><div class="ttname"><a href="a01738.html">tesseract</a></div><div class="ttdef"><b>Definition:</b> <a href="a00005_source.html#l00081">baseapi.cpp:81</a></div></div> <div class="ttc" id="a04161_html_a5e383045fdab001db353ec1621475389"><div class="ttname"><a href="a04161.html#a5e383045fdab001db353ec1621475389">tesseract::IntFeatureMap::InverseIndexFeature</a></div><div class="ttdeci">INT_FEATURE_STRUCT InverseIndexFeature(int index_feature) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00056">intfeaturemap.cpp:56</a></div></div> <div class="ttc" id="a02681_html_abb9516f874133b689b0e62ac70874385"><div class="ttname"><a href="a02681.html#abb9516f874133b689b0e62ac70874385">FCOORD::y</a></div><div class="ttdeci">float y() const</div><div class="ttdef"><b>Definition:</b> <a href="a00356_source.html#l00212">points.h:212</a></div></div> <div class="ttc" id="a04165_html_aa01d306fc0433b1d780d03aabc3a09c2"><div class="ttname"><a href="a04165.html#aa01d306fc0433b1d780d03aabc3a09c2">tesseract::IntFeatureSpace::Index</a></div><div class="ttdeci">int Index(const INT_FEATURE_STRUCT &f) const</div><div class="ttdef"><b>Definition:</b> <a href="a00722_source.html#l00065">intfeaturespace.h:65</a></div></div> <div class="ttc" id="a04165_html_afc33368d7ee0424316faffb752602fbf"><div class="ttname"><a href="a04165.html#afc33368d7ee0424316faffb752602fbf">tesseract::IntFeatureSpace::IndexAndSortFeatures</a></div><div class="ttdeci">void IndexAndSortFeatures(const INT_FEATURE_STRUCT *features, int num_features, GenericVector< int > *sorted_features) const</div><div class="ttdef"><b>Definition:</b> <a href="a00719_source.html#l00080">intfeaturespace.cpp:80</a></div></div> <div class="ttc" id="a04161_html_a9b4fdf30651a0e82cb852616f1f0fede"><div class="ttname"><a href="a04161.html#a9b4fdf30651a0e82cb852616f1f0fede">tesseract::IntFeatureMap::OffsetFeature</a></div><div class="ttdeci">int OffsetFeature(int index_feature, int dir) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00113">intfeaturemap.cpp:113</a></div></div> <div class="ttc" id="a02837_html_ab809f6fe92e0f3a7bce25eeb183ab120"><div class="ttname"><a href="a02837.html#ab809f6fe92e0f3a7bce25eeb183ab120">tesseract::IndexMapBiDi::CompleteMerges</a></div><div class="ttdeci">void CompleteMerges()</div><div class="ttdef"><b>Definition:</b> <a href="a00527_source.html#l00153">indexmapbidi.cpp:153</a></div></div> <div class="ttc" id="a00608_html_a02aa7cca2c3857c14716e8cca96ace6c"><div class="ttname"><a href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a></div><div class="ttdeci">#define tprintf(...)</div><div class="ttdef"><b>Definition:</b> <a href="a00608_source.html#l00031">tprintf.h:31</a></div></div> <div class="ttc" id="a00725_html_a1281b17b87e56c99d53fe6bb1f7c2d55"><div class="ttname"><a href="a00725.html#a1281b17b87e56c99d53fe6bb1f7c2d55">InitIntegerFX</a></div><div class="ttdeci">void InitIntegerFX()</div><div class="ttdef"><b>Definition:</b> <a href="a00725_source.html#l00055">intfx.cpp:55</a></div></div> <div class="ttc" id="a04165_html_a89de22c1c2aef24cae668aa656790161"><div class="ttname"><a href="a04165.html#a89de22c1c2aef24cae668aa656790161">tesseract::IntFeatureSpace::PositionFromIndex</a></div><div class="ttdeci">INT_FEATURE_STRUCT PositionFromIndex(int index) const</div><div class="ttdef"><b>Definition:</b> <a href="a00719_source.html#l00062">intfeaturespace.cpp:62</a></div></div> <div class="ttc" id="a02297_html_a20cfad5c58c50cb85a9529d8ddbd96af"><div class="ttname"><a href="a02297.html#a20cfad5c58c50cb85a9529d8ddbd96af">GenericVector::size</a></div><div class="ttdeci">int size() const</div><div class="ttdef"><b>Definition:</b> <a href="a00509_source.html#l00072">genericvector.h:72</a></div></div> <div class="ttc" id="a02681_html"><div class="ttname"><a href="a02681.html">FCOORD</a></div><div class="ttdef"><b>Definition:</b> <a href="a00356_source.html#l00189">points.h:189</a></div></div> <div class="ttc" id="a02837_html_a165b8de5eeba0557d206f76b556793d9"><div class="ttname"><a href="a02837.html#a165b8de5eeba0557d206f76b556793d9">tesseract::IndexMapBiDi::Init</a></div><div class="ttdeci">void Init(int size, bool all_mapped)</div><div class="ttdef"><b>Definition:</b> <a href="a00527_source.html#l00079">indexmapbidi.cpp:79</a></div></div> <div class="ttc" id="a02837_html_af016a084e6113d66cc0a7b18b3d7fb61"><div class="ttname"><a href="a02837.html#af016a084e6113d66cc0a7b18b3d7fb61">tesseract::IndexMapBiDi::IsCompactDeleted</a></div><div class="ttdeci">bool IsCompactDeleted(int index) const</div><div class="ttdef"><b>Definition:</b> <a href="a00530_source.html#l00130">indexmapbidi.h:130</a></div></div> <div class="ttc" id="a04221_html_af4a2ea6a7d9a82cba06f6ca9a126461b"><div class="ttname"><a href="a04221.html#af4a2ea6a7d9a82cba06f6ca9a126461b">INT_FEATURE_STRUCT::Theta</a></div><div class="ttdeci">uinT8 Theta</div><div class="ttdef"><b>Definition:</b> <a href="a00740_source.html#l00145">intproto.h:145</a></div></div> <div class="ttc" id="a04161_html_a928226c96da1c84d530b31540dd76fc2"><div class="ttname"><a href="a04161.html#a928226c96da1c84d530b31540dd76fc2">tesseract::IntFeatureMap::MapIndexFeature</a></div><div class="ttdeci">int MapIndexFeature(int index_feature) const</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00053">intfeaturemap.cpp:53</a></div></div> <div class="ttc" id="a04113_html"><div class="ttname"><a href="a04113.html">sample</a></div><div class="ttdef"><b>Definition:</b> <a href="a00668_source.html#l00032">cluster.h:32</a></div></div> <div class="ttc" id="a04285_html_aea58e8234a0b6bab9061929622150bb1"><div class="ttname"><a href="a04285.html#aea58e8234a0b6bab9061929622150bb1">tesseract::SampleIterator::Next</a></div><div class="ttdeci">void Next()</div><div class="ttdef"><b>Definition:</b> <a href="a00815_source.html#l00156">sampleiterator.cpp:156</a></div></div> <div class="ttc" id="a00521_html_a560c3ba94fe224dd67b10bd4cb5a6886"><div class="ttname"><a href="a00521.html#a560c3ba94fe224dd67b10bd4cb5a6886">Modulo</a></div><div class="ttdeci">int Modulo(int a, int b)</div><div class="ttdef"><b>Definition:</b> <a href="a00521_source.html#l00157">helpers.h:157</a></div></div> <div class="ttc" id="a02681_html_aecd85311c159bcd52b485a97a8dcc901"><div class="ttname"><a href="a02681.html#aecd85311c159bcd52b485a97a8dcc901">FCOORD::x</a></div><div class="ttdeci">float x() const</div><div class="ttdef"><b>Definition:</b> <a href="a00356_source.html#l00209">points.h:209</a></div></div> <div class="ttc" id="a04161_html_aa2a41837ff48a80829cf8c7d5ca4917d"><div class="ttname"><a href="a04161.html#aa2a41837ff48a80829cf8c7d5ca4917d">tesseract::IntFeatureMap::Init</a></div><div class="ttdeci">void TESS_API Init(const IntFeatureSpace &feature_space)</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00073">intfeaturemap.cpp:73</a></div></div> <div class="ttc" id="a00728_html"><div class="ttname"><a href="a00728.html">intfx.h</a></div></div> <div class="ttc" id="a04161_html_a9f520c6a69fa114d9eff812d936063a2"><div class="ttname"><a href="a04161.html#a9f520c6a69fa114d9eff812d936063a2">tesseract::IntFeatureMap::DeleteMapFeature</a></div><div class="ttdeci">void DeleteMapFeature(int map_feature)</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00063">intfeaturemap.cpp:63</a></div></div> <div class="ttc" id="a02837_html_a909e48dddc1488311f4d7083544eca56"><div class="ttname"><a href="a02837.html#a909e48dddc1488311f4d7083544eca56">tesseract::IndexMapBiDi::Setup</a></div><div class="ttdeci">void Setup()</div><div class="ttdef"><b>Definition:</b> <a href="a00527_source.html#l00095">indexmapbidi.cpp:95</a></div></div> <div class="ttc" id="a00716_html"><div class="ttname"><a href="a00716.html">intfeaturemap.h</a></div></div> <div class="ttc" id="a00725_html_a31bfe591242811378902d7342621a59b"><div class="ttname"><a href="a00725.html#a31bfe591242811378902d7342621a59b">FeatureDirection</a></div><div class="ttdeci">FCOORD FeatureDirection(uinT8 theta)</div><div class="ttdef"><b>Definition:</b> <a href="a00725_source.html#l00070">intfx.cpp:70</a></div></div> <div class="ttc" id="a02837_html_a3b4579cc4934a996ea688de031e758f2"><div class="ttname"><a href="a02837.html#a3b4579cc4934a996ea688de031e758f2">tesseract::IndexMapBiDi::SetMap</a></div><div class="ttdeci">void SetMap(int sparse_index, bool mapped)</div><div class="ttdef"><b>Definition:</b> <a href="a00527_source.html#l00088">indexmapbidi.cpp:88</a></div></div> <div class="ttc" id="a00500_html_a93a603f4063a6b9403d81caa245a583b"><div class="ttname"><a href="a00500.html#a93a603f4063a6b9403d81caa245a583b">ASSERT_HOST</a></div><div class="ttdeci">#define ASSERT_HOST(x)</div><div class="ttdef"><b>Definition:</b> <a href="a00500_source.html#l00084">errcode.h:84</a></div></div> <div class="ttc" id="a04221_html_a6b250df12a9b06b5ed0c1a7c403f0275"><div class="ttname"><a href="a04221.html#a6b250df12a9b06b5ed0c1a7c403f0275">INT_FEATURE_STRUCT::X</a></div><div class="ttdeci">uinT8 X</div><div class="ttdef"><b>Definition:</b> <a href="a00740_source.html#l00143">intproto.h:143</a></div></div> <div class="ttc" id="a02833_html_a33c1174b210b07024679d3c6f091c5b0"><div class="ttname"><a href="a02833.html#a33c1174b210b07024679d3c6f091c5b0">tesseract::IndexMap::CompactSize</a></div><div class="ttdeci">int CompactSize() const</div><div class="ttdef"><b>Definition:</b> <a href="a00530_source.html#l00061">indexmapbidi.h:61</a></div></div> <div class="ttc" id="a04165_html"><div class="ttname"><a href="a04165.html">tesseract::IntFeatureSpace</a></div><div class="ttdef"><b>Definition:</b> <a href="a00722_source.html#l00038">intfeaturespace.h:38</a></div></div> <div class="ttc" id="a04161_html_a3fbd4062c08d2b3234e43b6fb8278bca"><div class="ttname"><a href="a04161.html#a3fbd4062c08d2b3234e43b6fb8278bca">tesseract::IntFeatureMap::IntFeatureMap</a></div><div class="ttdeci">IntFeatureMap()</div><div class="ttdef"><b>Definition:</b> <a href="a00713_source.html#l00034">intfeaturemap.cpp:34</a></div></div> </div><!-- fragment --></div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="navelem"><a class="el" href="dir_31c6146c13abcc5d811ec2a212816f48.html">classify</a></li><li class="navelem"><a class="el" href="a00713.html">intfeaturemap.cpp</a></li> <li class="footer">Generated on Mon Oct 29 2018 11:27:49 for tesseract by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li> </ul> </div> </body> </html>