JeVoisBase  1.5
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
env_math.c
Go to the documentation of this file.
1 /*!@file Envision/env_math.c */
2 
3 // //////////////////////////////////////////////////////////////////// //
4 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 //
5 // by the University of Southern California (USC) and the iLab at USC. //
6 // See http://iLab.usc.edu for information about this project. //
7 // //////////////////////////////////////////////////////////////////// //
8 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
9 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
10 // in Visual Environments, and Applications'' by Christof Koch and //
11 // Laurent Itti, California Institute of Technology, 2001 (patent //
12 // pending; application number 09/912,225 filed July 23, 2001; see //
13 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). //
14 // //////////////////////////////////////////////////////////////////// //
15 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. //
16 // //
17 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can //
18 // redistribute it and/or modify it under the terms of the GNU General //
19 // Public License as published by the Free Software Foundation; either //
20 // version 2 of the License, or (at your option) any later version. //
21 // //
22 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope //
23 // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
24 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
25 // PURPOSE. See the GNU General Public License for more details. //
26 // //
27 // You should have received a copy of the GNU General Public License //
28 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write //
29 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, //
30 // Boston, MA 02111-1307 USA. //
31 // //////////////////////////////////////////////////////////////////// //
32 //
33 // Primary maintainer for this file: Rob Peters <rjpeters at usc dot edu>
34 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Envision/env_math.c $
35 // $Id: env_math.c 15495 2014-01-23 02:32:14Z itti $
36 //
37 
39 
42 
43 // ######################################################################
44 void env_init_integer_math(struct env_math* imath, const struct env_params* envp)
45 {
46  /* Trig tables generated with this matlab code:
47 
48  tabsize = 256;
49  tabbits = 8;
50  tabtype = 'intg16';
51 
52  arg=(2*pi*(0:(5*tabsize/4 - 1)) / tabsize);
53  sinarg=sin(arg);
54  sintab=fix(sinarg * (2^tabbits));
55 
56  fprintf('static const %s trigtab[] =\n', tabtype);
57  fprintf(' {\n');
58  fprintf([' /' '* *' '/ %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d,\n'], sintab);
59  fprintf(' };\n\n');
60 
61  */
62 
63  static const intg16 trigtab[] =
64  {
65  /* */ 0, 6, 12, 18, 25, 31, 37, 43, 49, 56, 62, 68, 74, 80, 86, 92,
66  /* */ 97, 103, 109, 115, 120, 126, 131, 136, 142, 147, 152, 157, 162, 167, 171, 176,
67  /* */ 181, 185, 189, 193, 197, 201, 205, 209, 212, 216, 219, 222, 225, 228, 231, 234,
68  /* */ 236, 238, 241, 243, 244, 246, 248, 249, 251, 252, 253, 254, 254, 255, 255, 255,
69  /* */ 256, 255, 255, 255, 254, 254, 253, 252, 251, 249, 248, 246, 244, 243, 241, 238,
70  /* */ 236, 234, 231, 228, 225, 222, 219, 216, 212, 209, 205, 201, 197, 193, 189, 185,
71  /* */ 181, 176, 171, 167, 162, 157, 152, 147, 142, 136, 131, 126, 120, 115, 109, 103,
72  /* */ 97, 92, 86, 80, 74, 68, 62, 56, 49, 43, 37, 31, 25, 18, 12, 6,
73  /* */ 0, -6, -12, -18, -25, -31, -37, -43, -49, -56, -62, -68, -74, -80, -86, -92,
74  /* */ -97, -103, -109, -115, -120, -126, -131, -136, -142, -147, -152, -157, -162, -167, -171, -176,
75  /* */ -181, -185, -189, -193, -197, -201, -205, -209, -212, -216, -219, -222, -225, -228, -231, -234,
76  /* */ -236, -238, -241, -243, -244, -246, -248, -249, -251, -252, -253, -254, -254, -255, -255, -255,
77  /* */ -256, -255, -255, -255, -254, -254, -253, -252, -251, -249, -248, -246, -244, -243, -241, -238,
78  /* */ -236, -234, -231, -228, -225, -222, -219, -216, -212, -209, -205, -201, -197, -193, -189, -185,
79  /* */ -181, -176, -171, -167, -162, -157, -152, -147, -142, -136, -131, -126, -120, -115, -109, -103,
80  /* */ -97, -92, -86, -80, -74, -68, -62, -56, -49, -43, -37, -31, -25, -18, -12, -6,
81  /* */ 0, 6, 12, 18, 25, 31, 37, 43, 49, 56, 62, 68, 74, 80, 86, 92,
82  /* */ 97, 103, 109, 115, 120, 126, 131, 136, 142, 147, 152, 157, 162, 167, 171, 176,
83  /* */ 181, 185, 189, 193, 197, 201, 205, 209, 212, 216, 219, 222, 225, 228, 231, 234,
84  /* */ 236, 238, 241, 243, 244, 246, 248, 249, 251, 252, 253, 254, 254, 255, 255, 255,
85  };
86 
87  typedef char trig_tab_size_check[ (sizeof(trigtab) / sizeof(trigtab[0]))
88  == (5*ENV_TRIG_TABSIZ/4) ? 1 : -1] __attribute__((unused));
89 
90  imath->nbits = envp->scale_bits;
91 
92  imath->sintab = &trigtab[0];
93  imath->costab = &trigtab[64];
94 }
short intg16
16-bit signed integer
Definition: env_types.h:46
const intg16 * sintab
Definition: env_math.h:51
env_size_t scale_bits
Definition: env_params.h:48
void env_init_integer_math(struct env_math *imath, const struct env_params *envp)
Definition: env_math.c:44
#define ENV_TRIG_TABSIZ
Definition: env_math.h:44
const intg16 * costab
Definition: env_math.h:52
env_size_t nbits
Definition: env_math.h:49