IntegerOrientationChannel.C
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 CHANNELS_INTEGERORIENTATIONCHANNEL_C_DEFINED
00039 #define CHANNELS_INTEGERORIENTATIONCHANNEL_C_DEFINED
00040
00041 #include "Channels/IntegerOrientationChannel.H"
00042
00043 #include "Channels/ChannelOpts.H"
00044 #include "Channels/IntegerSimpleChannel.H"
00045 #include "Component/OptionManager.H"
00046 #include "Image/ImageSetOps.H"
00047 #include "Image/IntegerMathOps.H"
00048 #include "Image/PyramidCache.H"
00049 #include "Util/sformat.H"
00050 #include "rutz/mutex.h"
00051 #include "rutz/trace.h"
00052
00053
00054
00055
00056
00057
00058 IntegerOrientationChannel::
00059 IntegerOrientationChannel(OptionManager& mgr,
00060 nub::ref<IntegerMathEngine> eng) :
00061 IntegerComplexChannel(mgr, "Integer Orientation",
00062 "int-orientation", ORI, eng),
00063 itsNumOrients(&OPT_NumOrientations, this)
00064 {
00065 GVX_TRACE(__PRETTY_FUNCTION__);
00066
00067
00068 buildSubChans();
00069 }
00070
00071
00072 void IntegerOrientationChannel::buildSubChans()
00073 {
00074 GVX_TRACE(__PRETTY_FUNCTION__);
00075
00076 this->removeAllSubChans();
00077
00078
00079
00080
00081
00082 LINFO("Using %d orientations spanning [0..180]deg", itsNumOrients.getVal());
00083 for (uint ori = 0; ori < itsNumOrients.getVal(); ++ori)
00084 {
00085 const double theta =
00086 180.0 * double(ori) / double(itsNumOrients.getVal());
00087
00088 nub::ref<IntegerSimpleChannel> chan
00089 (new IntegerSimpleChannel
00090 (getManager(),
00091 sformat("Integer Gabor (%d)", int(theta)),
00092 sformat("int-ori_%u", ori), UNKNOWN,
00093 rutz::make_shared(new IntgOrientedPyrBuilder
00094 (9, theta, this->getImath())),
00095 this->getMathEngine()));
00096
00097 chan->setNormalizeOutput(true);
00098
00099 this->addSubChan(chan);
00100
00101
00102 chan->exportOptions(MC_RECURSE);
00103 }
00104 }
00105
00106
00107 void IntegerOrientationChannel::paramChanged(ModelParamBase* const param,
00108 const bool valueChanged,
00109 ParamClient::ChangeStatus* status)
00110 {
00111 GVX_TRACE(__PRETTY_FUNCTION__);
00112 IntegerComplexChannel::paramChanged(param, valueChanged, status);
00113
00114
00115
00116 if (param == &itsNumOrients && valueChanged)
00117 buildSubChans();
00118 }
00119
00120
00121 IntegerOrientationChannel::~IntegerOrientationChannel()
00122 {
00123 GVX_TRACE(__PRETTY_FUNCTION__);
00124 }
00125
00126
00127 IntegerSimpleChannel& IntegerOrientationChannel::gabor(const uint idx) const
00128 {
00129 GVX_TRACE(__PRETTY_FUNCTION__);
00130
00131
00132 return *(dynCast<IntegerSimpleChannel>(subChan(idx)));
00133 }
00134
00135
00136 void IntegerOrientationChannel::doInputInt(const IntegerInput& inp,
00137 const SimTime& t,
00138 PyramidCache<int>* cache,
00139 const Image<byte>& clipMask)
00140 {
00141 GVX_TRACE(__PRETTY_FUNCTION__);
00142
00143 ASSERT(inp.grayInt().initialized());
00144
00145 if (numChans() == 0)
00146 return;
00147
00148 rutz::mutex_lock_class lock;
00149 if (cache && cache->laplacian9.beginSet(inp.grayInt(), &lock))
00150 {
00151 cache->laplacian9.endSet
00152 (inp.grayInt(),
00153 intgBuildPyrLaplacian
00154 (inp.grayInt(), gabor(0).getMinPyrLevel(),
00155 gabor(0).getMaxPyrLevel(), 9,
00156 this->getImath()),
00157 &lock);
00158 }
00159
00160 for (uint i = 0; i < numChans(); ++i)
00161 {
00162 gabor(i).inputInt(inp, t, cache, clipMask);
00163 LINFO("Orientation pyramid (%d/%d) ok.", i+1, numChans());
00164 }
00165 }
00166
00167
00168
00169
00170
00171
00172
00173
00174 #endif // CHANNELS_INTEGERORIENTATIONCHANNEL_C_DEFINED