Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

retina.h

Go to the documentation of this file.
00001 
00007 #ifndef __RETINA_H__
00008 #define __RETINA_H__
00009 
00010 #include <assert.h>
00011 #include <algorithm>
00012 
00013 #include "genericalgs.h"
00014 #include "robj.h"
00015 #include "neuralregion.h"
00016 #include "matrix.h"
00017 
00018 
00019 
00020 /******************************************************************************/
00021 /* General-purpose utility functions                                          */
00022 /******************************************************************************/
00023 
00034 template <class Matrix>
00035 void draw(Matrix& area, const Retinal_Obj* obj,
00036           const typename Matrix::value_type xoff=0.5,
00037           const typename Matrix::value_type yoff=0.5,
00038           const typename Matrix::value_type size_scale=1.0)
00039 {
00040   typedef typename Matrix::value_type T;
00041   typedef typename Matrix::size_type  Subscript;
00042 
00043   obj->update();
00044   const T s=1/size_scale;
00045   const T xo=xoff*s;
00046   const T yo=yoff*s;
00047   for (Subscript r=0; r<area.nrows(); r++) {
00048     const T y   = (area.nrows()-r-1)*s+yo; 
00049     for (Subscript c=0; c<area.ncols(); c++) {
00050       const T x   = c*s+xo;
00051       const T act = (obj? obj->activation(x,y) : 0);
00052       area[r][c]=act;
00053     }
00054   }
00055   //cout << gnuplot(area, "Area after draw") << endl;
00056 }
00057 
00058 
00059 
00060 /******************************************************************************/
00061 /* Retina classes                                                             */
00062 /******************************************************************************/
00063 
00064 
00066 class Retina : public NeuralRegion {
00067 public:
00068   Retina(string name_i, Subscript height, Subscript width,
00069          Activity& act_threshold, Activity xoff=0.5, Activity yoff=0.5 )
00070     : NeuralRegion(name_i, height, width), world_model(0),
00071       threshold(act_threshold), xo(xoff), yo(yoff) { }
00072 
00073   Retina(string name_i, Dimensions dims, Activity& act_threshold )
00074     : NeuralRegion(name_i, dims.height, dims.width), world_model(0),
00075       threshold(act_threshold), xo(dims.xoffset), yo(dims.yoffset) { }
00076   
00077   virtual ~Retina() { };
00078 
00079   virtual void activate(bool=false,bool=false) {
00080     draw(output, world_model, xo, yo);
00081     Generic::lower_threshold(MSEQ(output),threshold,0.0);
00082   }
00083 
00085   void set_input(const Retinal_Obj* const obj) {  world_model=obj;  };
00086   
00087 protected:
00089   const Retinal_Obj* world_model;
00091   Activity& threshold;
00094   const Activity xo,yo; 
00095 };
00096 
00097 
00098 #endif

Generated at Mon Aug 21 00:30:55 2000 for RF-LISSOM by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000