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 #include "Channels/DKLcolorChannel.H"
00039
00040 #include "Channels/ChannelOpts.H"
00041 #include "Channels/DcolorChannel.H"
00042 #include "Channels/KcolorChannel.H"
00043 #include "Channels/LcolorChannel.H"
00044 #include "Component/ModelOptionDef.H"
00045 #include "Component/OptionManager.H"
00046 #include "Image/ColorOps.H"
00047 #include "rutz/trace.h"
00048
00049 const ModelOptionDef OPT_DKLcolorChannelDweight =
00050 { MODOPT_ARG(float), "DKLcolorChannelDweight", &MOC_CHANNEL, OPTEXP_CORE,
00051 "Weight to assign to the D component of the DKL color channel",
00052 "dkl-d-weight", '\0', "<float>", "1.0" };
00053
00054 const ModelOptionDef OPT_DKLcolorChannelKweight =
00055 { MODOPT_ARG(float), "DKLcolorChannelKweight", &MOC_CHANNEL, OPTEXP_CORE,
00056 "Weight to assign to the K component of the DKL color channel",
00057 "dkl-k-weight", '\0', "<float>", "1.0" };
00058
00059 const ModelOptionDef OPT_DKLcolorChannelLweight =
00060 { MODOPT_ARG(float), "DKLcolorChannelLweight", &MOC_CHANNEL, OPTEXP_CORE,
00061 "Weight to assign to the L component of the DKL color channel",
00062 "dkl-l-weight", '\0', "<float>", "1.0" };
00063
00064
00065
00066
00067
00068 DKLcolorChannel::DKLcolorChannel(OptionManager& mgr) :
00069 ComplexChannel(mgr, "DKLcolor", "DKLcolor", DKLCOLOR),
00070 itsDweight(&OPT_DKLcolorChannelDweight, this),
00071 itsKweight(&OPT_DKLcolorChannelKweight, this),
00072 itsLweight(&OPT_DKLcolorChannelLweight, this),
00073 itsD(new DcolorChannel(getManager(), true)),
00074 itsK(new KcolorChannel(getManager(), true)),
00075 itsL(new LcolorChannel(getManager(), true))
00076 {
00077 GVX_TRACE(__PRETTY_FUNCTION__);
00078
00079 this->addSubChan(itsD);
00080 this->addSubChan(itsK);
00081 this->addSubChan(itsL);
00082 }
00083
00084
00085 DcolorChannel& DKLcolorChannel::Dcolor() const
00086 {
00087 GVX_TRACE(__PRETTY_FUNCTION__);
00088 return *itsD;
00089 }
00090
00091
00092 KcolorChannel& DKLcolorChannel::Kcolor() const
00093 {
00094 GVX_TRACE(__PRETTY_FUNCTION__);
00095 return *itsK;
00096 }
00097
00098
00099 LcolorChannel& DKLcolorChannel::Lcolor() const
00100 {
00101 GVX_TRACE(__PRETTY_FUNCTION__);
00102 return *itsL;
00103 }
00104
00105
00106 DKLcolorChannel::~DKLcolorChannel()
00107 {
00108 GVX_TRACE(__PRETTY_FUNCTION__);
00109 }
00110
00111
00112 void DKLcolorChannel::start1()
00113 {
00114 LINFO("Using a weight of %f for D subchannel", itsDweight.getVal());
00115 setSubchanTotalWeight(*itsD, itsDweight.getVal());
00116
00117 LINFO("Using a weight of %f for K subchannel", itsKweight.getVal());
00118 setSubchanTotalWeight(*itsK, itsKweight.getVal());
00119
00120 LINFO("Using a weight of %f for L subchannel", itsLweight.getVal());
00121 setSubchanTotalWeight(*itsL, itsLweight.getVal());
00122 }
00123
00124
00125 void DKLcolorChannel::doInput(const InputFrame& inframe)
00126 {
00127 GVX_TRACE(__PRETTY_FUNCTION__);
00128 Image<float> dimg, kimg, limg;
00129
00130
00131 LINFO("Converting input image to DKL colors.");
00132 getDKL(inframe.colorByte(), dimg, kimg, limg);
00133
00134
00135 itsD->input(InputFrame::fromGrayFloat(&dimg, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00136 itsK->input(InputFrame::fromGrayFloat(&kimg, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00137 itsL->input(InputFrame::fromGrayFloat(&limg, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00138 LINFO("DKL Color channel ok.");
00139 }
00140
00141
00142
00143
00144
00145