V1.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef V1_H_DEFINED
00039 #define V1_H_DEFINED
00040
00041
00042
00043 #include "Image/Image.H"
00044 #include "Image/ImageSet.H"
00045 #include "Image/Pixels.H"
00046 #include "Image/Layout.H"
00047 #include "Image/Point3D.H"
00048 #include "Image/TensorOps.H"
00049 #include "plugins/SceneUnderstanding/LGN.H"
00050 #include "Simulation/SimEvents.H"
00051 #include "Simulation/SimModule.H"
00052 #include "Media/MediaSimEvents.H"
00053 #include "Component/ModelOptionDef.H"
00054 #include "Component/OptionManager.H"
00055 #include "Component/ModelParam.H"
00056 #include "Util/CpuTimer.H"
00057
00058 #include <vector>
00059 #include <string>
00060
00061 class SimEventV1Bias;
00062 class V1 : public SimModule
00063 {
00064 public:
00065
00066 struct EdgesState
00067 {
00068 TensorField lumTensorField;
00069 TensorField rgTensorField;
00070 TensorField byTensorField;
00071 Image<float> prob;
00072 Image<float> distTr;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 };
00084
00085
00086 struct SpatialBias
00087 {
00088 Point2D<int> loc;
00089 Dims dims;
00090 float threshold;
00091
00092 SpatialBias() :
00093 loc(-1,-1),
00094 dims(0,0),
00095 threshold(0)
00096 {}
00097
00098 SpatialBias(int i, int j, int w, int h, float t) :
00099 loc(i,j),
00100 dims(w,h),
00101 threshold(t)
00102 {}
00103 bool contains(int x, int y)
00104 {
00105 if (!loc.isValid())
00106 return false;
00107
00108 if (x > loc.i - (dims.w()/2) &&
00109 x < loc.i + (dims.w()/2) &&
00110 y > loc.j - (dims.h()/2) &&
00111 y < loc.j + (dims.h()/2))
00112 return true;
00113 else
00114 return false;
00115
00116 }
00117
00118
00119 };
00120
00121
00122 V1(OptionManager& mgr, const std::string& descrName = "V1",
00123 const std::string& tagName = "V1");
00124
00125
00126 ~V1();
00127
00128 void evolve(SimEventQueue& q);
00129 void evolveGabor();
00130 void evolveSobel();
00131 void evolveCanny();
00132 void evolveTensor();
00133
00134 Layout<PixRGB<byte> > getDebugImage();
00135
00136 void setBias(const Image<float> &biasImg);
00137
00138 void applyThreshold(TensorField& tensorField, std::vector<SpatialBias>& spatialBias);
00139
00140 protected:
00141
00142 SIMCALLBACK_DECLARE(V1, SimEventLGNOutput);
00143
00144
00145 SIMCALLBACK_DECLARE(V1, SimEventV1Bias);
00146
00147
00148
00149 SIMCALLBACK_DECLARE(V1, SimEventSaveOutput);
00150
00151
00152 SIMCALLBACK_DECLARE(V1, SimEventUserInput);
00153
00154
00155
00156
00157 OModelParam<bool> itsShowDebug;
00158
00159 private:
00160
00161 ImageSet<float> itsLGNData;
00162 Image<float> itsInput;
00163 EdgesState itsEdgesState;
00164 float itsThreshold;
00165 float itsBiasThreshold;
00166 float itsAngBias;
00167 std::vector<SpatialBias> itsSpatialBias;
00168 Point2D<int> itsAttenLoc;
00169 Dims itsWinSize;
00170 CpuTimer itsTimer;
00171
00172 };
00173
00174
00175 class SimEventV1Output : public SimEvent
00176 {
00177 public:
00178 SimEventV1Output(SimModule* src,
00179 V1::EdgesState& edgesState) :
00180 SimEvent(src), itsEdgesState(edgesState)
00181 {}
00182
00183 virtual ~SimEventV1Output(){}
00184 V1::EdgesState getEdgesState() { return itsEdgesState; }
00185
00186 private:
00187 const V1::EdgesState itsEdgesState;
00188 };
00189
00190 class SimEventV1Bias : public SimEvent
00191 {
00192 public:
00193 SimEventV1Bias(SimModule* src,
00194 std::vector<V1::SpatialBias>& bias) :
00195 SimEvent(src), itsSpatialBias(bias)
00196 {}
00197
00198 virtual ~SimEventV1Bias(){}
00199 std::vector<V1::SpatialBias> getSpatialBias() { return itsSpatialBias; }
00200
00201 private:
00202 const std::vector<V1::SpatialBias>& itsSpatialBias;
00203 };
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 #endif //