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 #include "SpaceVariant/FovealTransformModule.H"
00037 #include "SpaceVariant/SpaceVariantTransforms.H"
00038 #include "SpaceVariant/SpaceVariantOpts.H"
00039 #include "Channels/ChannelOpts.H"
00040 #include "Neuro/NeuroOpts.H"
00041 #include "Image/CutPaste.H"
00042
00043
00044
00045
00046
00047
00048 FovealTransformModule::FovealTransformModule(OptionManager& mgr, const std::string& descrName, const std::string& tagName) :
00049 SpaceVariantModule(mgr, descrName, tagName),
00050 itsSvScale(&OPT_SpaceVariantScale, this),
00051 itsSvFovea(&OPT_SpaceVariantFoveaSize, this),
00052 itsSvSfac(&OPT_SpaceVariantSfac, this),
00053 itsSvBeta(&OPT_SpaceVariantBeta, this),
00054 itsSvGain(&OPT_SpaceVariantGain, this),
00055 itsSvExponent(&OPT_SpaceVariantExponent, this),
00056 itsSvOffset(&OPT_SpaceVariantOffset, this),
00057 itsFoveaCutoff(&OPT_SpaceVariantFovCut, this),
00058 itsSvDims(&OPT_SpaceVariantDims, this),
00059 itsPPD(&OPT_PixelsPerDegree, this),
00060 itsLevelSpec(&OPT_LevelSpec, this)
00061 { }
00062
00063
00064 FovealTransformModule::~FovealTransformModule()
00065 { }
00066
00067
00068 void FovealTransformModule::clear(const Dims& inp_dims)
00069 {
00070
00071 FovealTransform* t = new FovealTransform();
00072 t->setup(inp_dims.w(), inp_dims.h(),
00073 itsSvDims.getVal().w(), itsSvDims.getVal().h(),
00074 itsSvFovea.getVal(), itsSvBeta.getVal(),
00075 itsSvGain.getVal(), itsSvExponent.getVal(), itsSvOffset.getVal(),
00076 itsPPD.getVal().ppdx(), itsPPD.getVal().ppdy(),
00077 FovealTransform::toScaleType(itsSvScale.getVal()),
00078 itsSvSfac.getVal(), itsFoveaCutoff.getVal());
00079 itsTransform.reset(t);
00080
00081
00082 const int w = inp_dims.w() >> itsLevelSpec.getVal().mapLevel();
00083 const int h = inp_dims.h() >> itsLevelSpec.getVal().mapLevel();
00084 const int svw = itsSvDims.getVal().w()*2 >> itsLevelSpec.getVal().mapLevel();
00085 const int svh = itsSvDims.getVal().h()/2 >> itsLevelSpec.getVal().mapLevel();
00086
00087 FovealTransform* t1 = new FovealTransform();
00088 t1->setup(w, h, svw/2, svh*2,
00089 itsSvFovea.getVal(), itsSvBeta.getVal(),
00090 itsSvGain.getVal(), itsSvExponent.getVal(), itsSvOffset.getVal(),
00091 itsPPD.getVal().ppdx(), itsPPD.getVal().ppdy(),
00092 FovealTransform::toScaleType(itsSvScale.getVal()), itsSvSfac.getVal(), 0.0);
00093 itsMapTransform.reset(t1);
00094
00095 if ((w % 2 != 0) || (h % 2 != 0))
00096 LDEBUG("After pyramid operations, the input image is ideally divisible by two for "
00097 "space variant image processing. Try increasing the input image size or "
00098 "altering the pyramid depth or output level.");
00099
00100 if (svh % 2 != 0)
00101 LDEBUG("After pyramid operations, the transformed is ideally divisible by two for "
00102 "space variant image processing. Try increasing the space variant height (angles) or "
00103 "altering the pyramid depth or output level.");
00104
00105 LINFO("FovealTransform transform configured.");
00106 }
00107
00108
00109 template <class T_or_RGB>
00110 void FovealTransformModule::getFoveaPeriphery(const Image<T_or_RGB>& ret_image,
00111 Image<T_or_RGB>& fovea, Image<T_or_RGB>& periphery)
00112 {
00113 ::getFoveaPeriphery(static_cast<FovealTransform&>(*itsTransform), ret_image, fovea, periphery);
00114 }
00115
00116
00117 Dims FovealTransformModule::getSVDims() const
00118 {
00119 return itsSvDims.getVal();
00120 }
00121
00122 #define INST_CLASS FovealTransformModule::
00123 #include "inst/SpaceVariant/FovealTransformModule.I"
00124
00125
00126
00127
00128