#include namespace icl { using namespace std; // {{{ C++ fallback namespace{ template void apply_ws(const Img *src, Img *dst, const vector& weights) { ConstImgIterator itSrc = src->getROIIterator(0); ImgIterator itDst = dst->getROIIterator(0); D w = weights[0]; for(;itSrc.inRegion(); ++itSrc, ++itDst){ *itDst = *itSrc * w; } for (int c=src->getChannels()-1; c > 0; c--) { w = weights[c]; itSrc = src->getROIIterator(c); itDst = dst->getROIIterator(0); for(;itSrc.inRegion(); ++itSrc, ++itDst){ *itDst += *itSrc * w; } } } } // }}} void WeightedSumOp::apply (const ImgBase *poSrc, ImgBase **ppoDst){ ICLASSERT_RETURN(poSrc); ICLASSERT_RETURN( (int)m_vecWeights.size() == poSrc->getChannels() ); if(!prepare(ppoDst, poSrc->getDepth() == depth64f ? depth64f : depth32f, getClipToROI() ? poSrc->getROISize() : poSrc->getSize(), formatMatrix,1,getClipToROI() ? Rect(Point::null,poSrc->getROISize()) : poSrc->getROI(), poSrc->getTime()) ) return; if((*ppoDst)->getDepth() == depth64f){ switch (poSrc->getDepth()) { #define ICL_INSTANTIATE_DEPTH(D) case depth##D: apply_ws(poSrc->asImg(),(*ppoDst)->asImg(),m_vecWeights); break; ICL_INSTANTIATE_ALL_DEPTHS; #undef ICL_INSTANTIATE_DEPTH } }else{ vector v(m_vecWeights.size()); for(unsigned int i=0;igetDepth()) { #define ICL_INSTANTIATE_DEPTH(D) case depth##D: apply_ws(poSrc->asImg(),(*ppoDst)->asImg(),v); break; ICL_INSTANTIATE_ALL_DEPTHS; #undef ICL_INSTANTIATE_DEPTH } } } }