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 JUNCTIONCHANNEL_C_DEFINED
00039 #define JUNCTIONCHANNEL_C_DEFINED
00040
00041 #include "Channels/JunctionChannel.H"
00042
00043 #include "Channels/ChannelOpts.H"
00044 #include "Channels/ComplexChannel.H"
00045 #include "Channels/OrientationChannel.H"
00046 #include "Component/OptionManager.H"
00047 #include "Image/FilterOps.H"
00048 #include "Util/sformat.H"
00049 #include "rutz/trace.h"
00050
00051
00052
00053
00054 JunctionChannel::JunctionChannel(OptionManager& mgr,
00055 nub::soft_ref<OrientationChannel> oc,
00056 const VisualFeature vs,
00057 const int r0, const int r1, const int r2,
00058 const int r3, const int r4, const int r5,
00059 const int r6, const int r7) :
00060 SingleChannel(mgr, "JunctionChannel", "JunctionChannel", vs,
00061 rutz::shared_ptr< PyrBuilder<float> >(NULL)),
00062 itsFull(vs == LJUNCTION ? &OPT_LFullImplementation :
00063 vs == TJUNCTION ? &OPT_TFullImplementation :
00064 vs == XJUNCTION ? &OPT_XFullImplementation :
00065 vs == ENDPOINT ? &OPT_EFullImplementation :
00066 (ModelOptionDef*) 0,
00067 this),
00068 itsDelta(vs == LJUNCTION ? &OPT_LJunctionChannelDelta :
00069 vs == TJUNCTION ? &OPT_TJunctionChannelDelta :
00070 vs == XJUNCTION ? &OPT_XJunctionChannelDelta :
00071 vs == ENDPOINT ? &OPT_EndPointChannelDelta :
00072 (ModelOptionDef*) 0,
00073 this),
00074 itsOriChan(oc),
00075 R0(r0), R1(r1), R2(r2), R3(r3), R4(r4), R5(r5), R6(r6), R7(r7)
00076 {
00077 GVX_TRACE(__PRETTY_FUNCTION__);
00078 itsTakeAbs.setVal(true);
00079
00080 setDescriptiveName(sformat("Junction(%d%d%d%d%d%d%d%d)",
00081 r0, r1, r2, r3, r4, r5, r6, r7));
00082
00083 setTagName(sformat("junction_%d%d%d%d%d%d%d%d",
00084 r0, r1, r2, r3, r4, r5, r6, r7));
00085 }
00086
00087
00088 JunctionChannel::~JunctionChannel()
00089 {
00090 GVX_TRACE(__PRETTY_FUNCTION__);
00091 }
00092
00093
00094 void JunctionChannel::doInput(const InputFrame& inframe)
00095 {
00096 GVX_TRACE(__PRETTY_FUNCTION__);
00097
00098 ASSERT(itsOriChan.get() != 0);
00099 const uint num = itsOriChan->getModelParamVal<uint>("NumOrientations");
00100 ASSERT(num == 4);
00101
00102
00103
00104 const ImageSet<float>& ori0_pyr =
00105 dynCast<SingleChannel>(itsOriChan->subChan(0))->pyramid(0);
00106 const ImageSet<float>& ori45_pyr =
00107 dynCast<SingleChannel>(itsOriChan->subChan(1))->pyramid(0);
00108 const ImageSet<float>& ori90_pyr =
00109 dynCast<SingleChannel>(itsOriChan->subChan(2))->pyramid(0);
00110 const ImageSet<float>& ori135_pyr =
00111 dynCast<SingleChannel>(itsOriChan->subChan(3))->pyramid(0);
00112
00113 ImageSet<float> result(ori0_pyr.size());
00114 SingleChannel::killCaches();
00115 SingleChannel::setClipPyramid(inframe.clipMask());
00116
00117 const bool R[8] = { (bool)R0, (bool)R1, (bool)R2, (bool)R3, (bool)R4,
00118 (bool)R5, (bool)R6, (bool)R7 };
00119
00120 const uint dx = itsDelta.getVal();
00121 const uint dy = itsDelta.getVal();
00122
00123
00124
00125
00126
00127 if (itsFull.getVal())
00128 {
00129 for (uint i = 0; i < ori0_pyr.size(); i ++)
00130 result[i] = junctionFilterFull(ori0_pyr[i], ori45_pyr[i],
00131 ori90_pyr[i], ori135_pyr[i],
00132 R, dx, dy);
00133 }
00134 else
00135 {
00136 for (uint i = 0; i < ori0_pyr.size(); i ++)
00137 result[i] = junctionFilterPartial(ori0_pyr[i], ori45_pyr[i],
00138 ori90_pyr[i], ori135_pyr[i],
00139 R, dx, dy);
00140 }
00141
00142
00143 SingleChannel::storePyramid(result, inframe.time());
00144 }
00145
00146
00147
00148
00149
00150
00151
00152 #endif // JUNCTIONCHANNEL_C_DEFINED