/* * Copyright (c) 2000, University of Amsterdam, The Netherlands. * All rights reserved. * * Author(s): * Dennis Koelma (koelma@wins.uva.nl) * */ #include "HxImageToHistogram.h" #include "HxImgFtorInOut.h" #include "HxIncludedSigs.h" template<class ValT> class HxInOutHistogram { public: typedef HxTagPixOpOut DirectionCategory; typedef HxTagTransInVar TransVarianceCategory; typedef HxTag1Phase PhaseCategory; HxInOutHistogram(HxTagList&); void doIt(const ValT& pixV); static HxString className(); private: HxHistogram* _hist; int _getDim; }; template<class ValT> HxInOutHistogram<ValT>::HxInOutHistogram(HxTagList& tags) { _hist = HxGetTag(tags, "histogram", (HxHistogram*)0); _getDim = HxGetTag<int>(tags, "getDim"); } template<class ValT> inline void HxInOutHistogram<ValT>::doIt(const ValT& pixV) { if (_getDim <= 0) _hist->insertVal(pixV); else _hist->insertVal(((ValT) pixV).getValue(_getDim)); } template<class ValT> HxString HxInOutHistogram<ValT>::className() { return HxString("histogram"); } template<class ImgSigT> struct HxInstantiatorHistogram { HxImgFtorInOut<ImgSigT, HxInOutHistogram<typename ImgSigT::ArithType> > f; }; HxAlwaysInstantiateHistogram::HxAlwaysInstantiateHistogram() { } namespace HxImageToHistogram_c { static HxInstantiatorHistogram<HxImageSig2dByte> f001; static HxInstantiatorHistogram<HxImageSig2dShort> f002; static HxInstantiatorHistogram<HxImageSig2dInt> f003; static HxInstantiatorHistogram<HxImageSig2dFloat> f004; static HxInstantiatorHistogram<HxImageSig2dDouble> f005; static HxInstantiatorHistogram<HxImageSig2dVec2Byte> f006; static HxInstantiatorHistogram<HxImageSig2dVec2Short> f007; static HxInstantiatorHistogram<HxImageSig2dVec2Int> f008; static HxInstantiatorHistogram<HxImageSig2dVec2Float> f009; static HxInstantiatorHistogram<HxImageSig2dVec2Double> f010; static HxInstantiatorHistogram<HxImageSig2dVec3Byte> f011; static HxInstantiatorHistogram<HxImageSig2dVec3Short> f012; static HxInstantiatorHistogram<HxImageSig2dVec3Int> f013; static HxInstantiatorHistogram<HxImageSig2dVec3Float> f014; static HxInstantiatorHistogram<HxImageSig2dVec3Double> f015; static HxInstantiatorHistogram<HxImageSig3dByte> f016; static HxInstantiatorHistogram<HxImageSig3dShort> f017; static HxInstantiatorHistogram<HxImageSig3dInt> f018; static HxInstantiatorHistogram<HxImageSig3dFloat> f019; static HxInstantiatorHistogram<HxImageSig3dDouble> f020; }; HxHistogram HxImageToHistogram(HxImageRep im, int getDim, double lowBin, double highBin, int nBin) { int nDim = (getDim <= 0) ? im.pixelDimensionality() : 1; HxHistogram hist = HxHistogram(REAL_VALUE, nDim, lowBin, highBin, nBin, lowBin, highBin, nBin, lowBin, highBin, nBin); HxTagList tags; HxAddTag(tags, "histogram", &hist); HxAddTag(tags, "getDim", getDim); im.exportOp("histogram", tags); return hist; }