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 SOCOLORCHANNEL_C_DEFINED
00039 #define SOCOLORCHANNEL_C_DEFINED
00040
00041 #include "Channels/SOColorChannel.H"
00042
00043 #include "Channels/BlueChannel.H"
00044 #include "Channels/GreenChannel.H"
00045 #include "Channels/RedChannel.H"
00046 #include "Channels/SOBlueYellowChannel.H"
00047 #include "Channels/SOGreenRedChannel.H"
00048 #include "Channels/SORedGreenChannel.H"
00049 #include "Channels/SOYellowBlueChannel.H"
00050 #include "Channels/YellowChannel.H"
00051 #include "Image/ColorOps.H"
00052 #include "rutz/trace.h"
00053
00054
00055
00056
00057 SOColorChannel::SOColorChannel(OptionManager& mgr) :
00058 ComplexChannel(mgr, "SOColor", "single-opponent-color", SOCOLOR),
00059 itsLumThresh("ColorChannelLuminanceThreshold", this, 25.5F),
00060 itsRG(makeSharedComp(new SORedGreenChannel(mgr))),
00061 itsGR(makeSharedComp(new SOGreenRedChannel(mgr))),
00062 itsBY(makeSharedComp(new SOBlueYellowChannel(mgr))),
00063 itsYB(makeSharedComp(new SOYellowBlueChannel(mgr))),
00064 itsR(makeSharedComp(new RedChannel(mgr))),
00065 itsG(makeSharedComp(new GreenChannel(mgr))),
00066 itsB(makeSharedComp(new BlueChannel(mgr))),
00067 itsY(makeSharedComp(new YellowChannel(mgr)))
00068 {
00069 GVX_TRACE(__PRETTY_FUNCTION__);
00070 this->addSubChan(itsRG);
00071 this->addSubChan(itsGR);
00072 this->addSubChan(itsBY);
00073 this->addSubChan(itsYB);
00074
00075
00076
00077 this->addSubChan(itsR);
00078 this->addSubChan(itsG);
00079 this->addSubChan(itsB);
00080 this->addSubChan(itsY);
00081
00082
00083 this->setSubchanTotalWeight(*itsR, 0.0);
00084 this->setSubchanTotalWeight(*itsG, 0.0);
00085 this->setSubchanTotalWeight(*itsB, 0.0);
00086 this->setSubchanTotalWeight(*itsY, 0.0);
00087 }
00088
00089
00090 SORedGreenChannel& SOColorChannel::rg() const { return *itsRG; }
00091 SOGreenRedChannel& SOColorChannel::gr() const { return *itsGR; }
00092 SOBlueYellowChannel& SOColorChannel::by() const { return *itsBY; }
00093 SOYellowBlueChannel& SOColorChannel::yb() const { return *itsYB; }
00094 RedChannel& SOColorChannel::r() const { return *itsR; }
00095 GreenChannel& SOColorChannel::g() const { return *itsG; }
00096 BlueChannel& SOColorChannel::b() const { return *itsB; }
00097 YellowChannel& SOColorChannel::y() const { return *itsY; }
00098
00099
00100 SOColorChannel::~SOColorChannel()
00101 {
00102 GVX_TRACE(__PRETTY_FUNCTION__);
00103 }
00104
00105
00106 void SOColorChannel::doInput(const InputFrame& inframe)
00107 {
00108 GVX_TRACE(__PRETTY_FUNCTION__);
00109 ASSERT(inframe.colorFloat().initialized());
00110
00111 Image<float> red, green, blue, yellow;
00112 getRGBY(inframe.colorFloat(), red, green, blue, yellow,
00113 itsLumThresh.getVal());
00114
00115 itsR->input(InputFrame::fromGrayFloat
00116 (&red, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00117 itsG->input(InputFrame::fromGrayFloat
00118 (&green, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00119 itsB->input(InputFrame::fromGrayFloat
00120 (&blue, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00121 itsY->input(InputFrame::fromGrayFloat
00122 (&yellow, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00123
00124 const Dims d = inframe.getDims();
00125
00126
00127
00128 rg().singleOpponentInput(d, r().pyramid(0), g().pyramid(0),
00129 inframe.time(), inframe.clipMask());
00130 gr().singleOpponentInput(d, g().pyramid(0), r().pyramid(0),
00131 inframe.time(), inframe.clipMask());
00132 by().singleOpponentInput(d, b().pyramid(0), y().pyramid(0),
00133 inframe.time(), inframe.clipMask());
00134 yb().singleOpponentInput(d, y().pyramid(0), b().pyramid(0),
00135 inframe.time(), inframe.clipMask());
00136 LINFO("Single Opponent Color channel ok.");
00137 }
00138
00139
00140 void SOColorChannel::setRG(nub::ref<SORedGreenChannel> RG)
00141 { this->removeSubChan(itsRG); itsRG = RG; this->addSubChan(itsRG); }
00142
00143 void SOColorChannel::setGR(nub::ref<SOGreenRedChannel> GR)
00144 { this->removeSubChan(itsGR); itsGR = GR; this->addSubChan(itsGR); }
00145
00146 void SOColorChannel::setBY(nub::ref<SOBlueYellowChannel> BY)
00147 { this->removeSubChan(itsBY); itsBY = BY; this->addSubChan(itsBY); }
00148
00149 void SOColorChannel::setYB(nub::ref<SOYellowBlueChannel> YB)
00150 { this->removeSubChan(itsYB); itsYB = YB; this->addSubChan(itsYB); }
00151
00152 void SOColorChannel::setR(nub::ref<RedChannel> R)
00153 { this->removeSubChan(itsR); itsR = R; this->addSubChan(itsR); }
00154
00155 void SOColorChannel::setG(nub::ref<GreenChannel> G)
00156 { this->removeSubChan(itsG); itsG = G; this->addSubChan(itsG); }
00157
00158 void SOColorChannel::setB(nub::ref<BlueChannel> B)
00159 { this->removeSubChan(itsB); itsB = B; this->addSubChan(itsB); }
00160
00161 void SOColorChannel::setY(nub::ref<YellowChannel> Y)
00162 { this->removeSubChan(itsY); itsY = Y; this->addSubChan(itsY); }
00163
00164
00165
00166
00167
00168
00169
00170
00171 #endif // SOCOLORCHANNEL_C_DEFINED