#include #include #include using namespace icl; template void print (Img &src, Img &dst, std::vector::iterator wIt) { printf ("weighted sum: %s", translateDepth (src.getDepth()).c_str()); for (int c=0; c < src.getChannels(); c++, wIt++) { printf ("\nchannel %d: w=%4.2f ", c, *wIt); for (ImgIterator it = src.getIterator(c);it.inRegion();++it) printf("%4.1f,", (float) *it); } printf ("\nresult: "); for (ImgIterator it = dst.getIterator(0);it.inRegion();++it) printf("%4.1f,", *it); printf ("\n"); } void performance (depth eDepth) { ImgBase *pSrc = imgNew (eDepth, Size(1000,1000), 10); Img32f dst (Size(1000,1000),1); std::vector weights(10); Timer t; printf("\nWeightedSum Benchmark: %s", translateDepth (eDepth).c_str()); int N = 10; WeightedSum ws; ws.apply (pSrc, &dst, weights); t.start(); for (int i=0;i(apfSrc, apfSrc+2)); Img32f dst (size,1); std::vector weights; weights.push_back(2); weights.push_back(0.5); WeightedSum ws; ws.apply (&src32, &dst, weights); print (src32, dst, weights.begin()); icl8u auSrc[2][4] = { {1, 2, 3, 4}, {4, 3, 2, 1}}; icl8u* apuSrc[2] = {auSrc[0], auSrc[1]}; Img8u src8u (size, 2, std::vector(apuSrc, apuSrc+2)); ws.apply (&src8u, &dst, weights); print (src8u, dst, weights.begin()); performance (depth8u); performance (depth16s); performance (depth32s); performance (depth32f); performance (depth64f); return 0; }