36 #ifndef VIGRA_ACCUMULATOR_HXX 37 #define VIGRA_ACCUMULATOR_HXX 40 #pragma warning (disable: 4503) 43 #include "accumulator-grammar.hxx" 45 #include "metaprogramming.hxx" 46 #include "bit_array.hxx" 47 #include "static_assert.hxx" 48 #include "mathutil.hxx" 49 #include "utilities.hxx" 50 #include "multi_iterator_coupled.hxx" 52 #include "multi_math.hxx" 53 #include "eigensystem.hxx" 54 #include "histogram.hxx" 385 template <
class T01=void,
class T02=void,
class T03=void,
class T04=void,
class T05=void,
386 class T06=void,
class T07=void,
class T08=void,
class T09=void,
class T10=void,
387 class T11=void,
class T12=void,
class T13=void,
class T14=void,
class T15=void,
388 class T16=void,
class T17=void,
class T18=void,
class T19=void,
class T20=
void>
390 :
public MakeTypeList<
391 typename StandardizeTag<T01>::type, typename StandardizeTag<T02>::type, typename StandardizeTag<T03>::type,
392 typename StandardizeTag<T04>::type, typename StandardizeTag<T05>::type, typename StandardizeTag<T06>::type,
393 typename StandardizeTag<T07>::type, typename StandardizeTag<T08>::type, typename StandardizeTag<T09>::type,
394 typename StandardizeTag<T10>::type, typename StandardizeTag<T11>::type, typename StandardizeTag<T12>::type,
395 typename StandardizeTag<T13>::type, typename StandardizeTag<T14>::type, typename StandardizeTag<T15>::type,
396 typename StandardizeTag<T16>::type, typename StandardizeTag<T17>::type, typename StandardizeTag<T18>::type,
397 typename StandardizeTag<T19>::type, typename StandardizeTag<T20>::type
402 template <
class T01,
class T02,
class T03,
class T04,
class T05,
403 class T06,
class T07,
class T08,
class T09,
class T10,
404 class T11,
class T12,
class T13,
class T14,
class T15,
405 class T16,
class T17,
class T18,
class T19,
class T20>
406 struct StandardizeTag<Select<T01, T02, T03, T04, T05,
407 T06, T07, T08, T09, T10,
408 T11, T12, T13, T14, T15,
409 T16, T17, T18, T19, T20>,
410 Select<T01, T02, T03, T04, T05,
411 T06, T07, T08, T09, T10,
412 T11, T12, T13, T14, T15,
413 T16, T17, T18, T19, T20> >
415 typedef typename Select<T01, T02, T03, T04, T05,
416 T06, T07, T08, T09, T10,
417 T11, T12, T13, T14, T15,
418 T16, T17, T18, T19, T20>::type type;
421 struct AccumulatorBegin
425 static std::string name()
427 return "AccumulatorBegin (internal)";
432 template <
class T,
class BASE>
439 struct AccumulatorEnd;
444 struct LabelDispatchTag;
446 struct Error__Global_statistics_are_only_defined_for_AccumulatorChainArray;
458 static std::string name()
460 return std::string(
"LabelArg<") + asString(INDEX) +
"> (internal)";
465 template <
class T,
class BASE>
469 typedef LabelArgTag Tag;
470 typedef void value_type;
471 typedef void result_type;
473 static const int value = INDEX;
474 static const unsigned int workInPass = 0;
484 static std::string name()
486 return std::string(
"CoordArg<") + asString(INDEX) +
"> (internal)";
491 template <
class T,
class BASE>
495 typedef CoordArgTag Tag;
496 typedef void value_type;
497 typedef void result_type;
499 static const int value = INDEX;
500 static const unsigned int workInPass = 0;
504 template <
class T,
class TAG,
class NEXT=AccumulatorEnd>
505 struct AccumulatorBase;
507 template <
class Tag,
class A>
510 template <
class Tag,
class A,
class TargetTag=
typename A::Tag>
511 struct LookupDependency;
513 #ifndef _MSC_VER // compiler bug? (causes 'ambiguous overload error') 515 template <
class TAG,
class A>
516 typename LookupTag<TAG, A>::reference
519 template <
class TAG,
class A>
520 typename LookupDependency<TAG, A>::result_type
521 getDependency(A
const & a);
525 namespace acc_detail {
536 struct PushArgTagToTail
541 #define VIGRA_PUSHARGTAG(TAG) \ 542 template <int INDEX, class TAIL> \ 543 struct PushArgTagToTail<TypeList<TAG<INDEX>, TAIL> > \ 545 typedef typename Push<TAIL, TypeList<TAG<INDEX> > >::type type; \ 550 VIGRA_PUSHARGTAG(CoordArg)
553 #undef VIGRA_PUSHARGTAG 559 struct AddDependencies;
561 template <
class HEAD,
class TAIL>
562 struct AddDependencies<TypeList<HEAD, TAIL> >
564 typedef typename AddDependencies<TAIL>::type TailWithDependencies;
565 typedef typename StandardizeDependencies<HEAD>::type HeadDependencies;
566 typedef typename AddDependencies<HeadDependencies>::type TransitiveHeadDependencies;
567 typedef TypeList<HEAD, TransitiveHeadDependencies> HeadWithDependencies;
568 typedef typename PushUnique<HeadWithDependencies, TailWithDependencies>::type UnsortedDependencies;
569 typedef typename PushArgTagToTail<UnsortedDependencies>::type type;
573 struct AddDependencies<void>
580 template <
class Dependencies>
581 struct ActivateDependencies;
583 template <
class HEAD,
class TAIL>
584 struct ActivateDependencies<TypeList<HEAD, TAIL> >
586 template <
class Chain,
class ActiveFlags>
587 static void exec(ActiveFlags & flags)
589 LookupTag<HEAD, Chain>::type::activateImpl(flags);
590 ActivateDependencies<TAIL>::template exec<Chain>(flags);
593 template <
class Chain,
class ActiveFlags,
class GlobalFlags>
594 static void exec(ActiveFlags & flags, GlobalFlags & gflags)
596 LookupTag<HEAD, Chain>::type::template activateImpl<Chain>(flags, gflags);
597 ActivateDependencies<TAIL>::template exec<Chain>(flags, gflags);
601 template <
class HEAD,
class TAIL>
602 struct ActivateDependencies<TypeList<Global<HEAD>, TAIL> >
604 template <
class Chain,
class ActiveFlags,
class GlobalFlags>
605 static void exec(ActiveFlags & flags, GlobalFlags & gflags)
607 LookupTag<Global<HEAD>, Chain>::type::activateImpl(gflags);
608 ActivateDependencies<TAIL>::template exec<Chain>(flags, gflags);
613 struct ActivateDependencies<void>
615 template <
class Chain,
class ActiveFlags>
616 static void exec(ActiveFlags &)
619 template <
class Chain,
class ActiveFlags,
class GlobalFlags>
620 static void exec(ActiveFlags &, GlobalFlags &)
624 template <
class List>
625 struct SeparateGlobalAndRegionTags;
627 template <
class HEAD,
class TAIL>
628 struct SeparateGlobalAndRegionTags<TypeList<HEAD, TAIL> >
630 typedef SeparateGlobalAndRegionTags<TAIL> Inner;
631 typedef TypeList<HEAD, typename Inner::RegionTags> RegionTags;
632 typedef typename Inner::GlobalTags GlobalTags;
635 template <
class HEAD,
class TAIL>
636 struct SeparateGlobalAndRegionTags<TypeList<Global<HEAD>, TAIL> >
638 typedef SeparateGlobalAndRegionTags<TAIL> Inner;
639 typedef typename Inner::RegionTags RegionTags;
640 typedef TypeList<HEAD, typename Inner::GlobalTags> GlobalTags;
643 template <
int INDEX,
class TAIL>
644 struct SeparateGlobalAndRegionTags<TypeList<DataArg<INDEX>, TAIL> >
646 typedef SeparateGlobalAndRegionTags<TAIL> Inner;
647 typedef TypeList<DataArg<INDEX>,
typename Inner::RegionTags> RegionTags;
648 typedef TypeList<DataArg<INDEX>,
typename Inner::GlobalTags> GlobalTags;
651 template <
int INDEX,
class TAIL>
652 struct SeparateGlobalAndRegionTags<TypeList<LabelArg<INDEX>, TAIL> >
654 typedef SeparateGlobalAndRegionTags<TAIL> Inner;
655 typedef typename Inner::RegionTags RegionTags;
656 typedef TypeList<LabelArg<INDEX>,
typename Inner::GlobalTags> GlobalTags;
659 template <
int INDEX,
class TAIL>
660 struct SeparateGlobalAndRegionTags<TypeList<WeightArg<INDEX>, TAIL> >
662 typedef SeparateGlobalAndRegionTags<TAIL> Inner;
663 typedef TypeList<WeightArg<INDEX>,
typename Inner::RegionTags> RegionTags;
664 typedef TypeList<WeightArg<INDEX>,
typename Inner::GlobalTags> GlobalTags;
667 template <
int INDEX,
class TAIL>
668 struct SeparateGlobalAndRegionTags<TypeList<CoordArg<INDEX>, TAIL> >
670 typedef SeparateGlobalAndRegionTags<TAIL> Inner;
671 typedef TypeList<CoordArg<INDEX>,
typename Inner::RegionTags> RegionTags;
672 typedef TypeList<CoordArg<INDEX>,
typename Inner::GlobalTags> GlobalTags;
676 struct SeparateGlobalAndRegionTags<void>
678 typedef void RegionTags;
679 typedef void GlobalTags;
688 template <
class Accumulators>
689 struct CollectAccumulatorNames;
691 template <
class HEAD,
class TAIL>
692 struct CollectAccumulatorNames<TypeList<HEAD, TAIL> >
694 template <
class BackInsertable>
695 static void exec(BackInsertable & a,
bool skipInternals=
true)
697 if(!skipInternals || HEAD::name().find(
"internal") == std::string::npos)
698 a.push_back(HEAD::name());
699 CollectAccumulatorNames<TAIL>::exec(a, skipInternals);
704 struct CollectAccumulatorNames<void>
706 template <
class BackInsertable>
707 static void exec(BackInsertable & a,
bool skipInternals=
true)
712 struct ApplyVisitorToTag;
714 template <
class HEAD,
class TAIL>
715 struct ApplyVisitorToTag<TypeList<HEAD, TAIL> >
717 template <
class Accu,
class Visitor>
718 static bool exec(Accu & a, std::string
const & tag, Visitor
const & v)
720 static std::string * name = VIGRA_SAFE_STATIC(name,
new std::string(normalizeString(HEAD::name())));
723 v.template exec<HEAD>(a);
728 return ApplyVisitorToTag<TAIL>::exec(a, tag, v);
734 struct ApplyVisitorToTag<void>
736 template <
class Accu,
class Visitor>
737 static bool exec(Accu & a, std::string
const & tag, Visitor
const & v)
743 struct ActivateTag_Visitor
745 template <
class TAG,
class Accu>
746 void exec(Accu & a)
const 748 a.template activate<TAG>();
752 struct TagIsActive_Visitor
756 template <
class TAG,
class Accu>
757 void exec(Accu & a)
const 759 result = a.template isActive<TAG>();
770 struct SetHistogramBincount
772 template <
class Accu>
777 template <
template <
int>
class Histogram>
778 struct SetHistogramBincount<Histogram<0> >
780 template <
class Accu>
788 struct ApplyHistogramOptions
790 template <
class Accu>
796 struct ApplyHistogramOptions<StandardQuantiles<TAG> >
798 template <
class Accu>
803 template <
class TAG,
template <
class>
class MODIFIER>
804 struct ApplyHistogramOptions<MODIFIER<TAG> >
805 :
public ApplyHistogramOptions<TAG>
809 struct ApplyHistogramOptions<IntegerHistogram<0> >
811 template <
class Accu>
814 SetHistogramBincount<IntegerHistogram<0> >::exec(a, options);
818 template <
int BinCount>
819 struct ApplyHistogramOptions<UserRangeHistogram<BinCount> >
821 template <
class Accu>
824 SetHistogramBincount<UserRangeHistogram<BinCount> >::exec(a, options);
830 template <
int BinCount>
831 struct ApplyHistogramOptions<AutoRangeHistogram<BinCount> >
833 template <
class Accu>
836 SetHistogramBincount<AutoRangeHistogram<BinCount> >::exec(a, options);
842 template <
int BinCount>
843 struct ApplyHistogramOptions<GlobalRangeHistogram<BinCount> >
845 template <
class Accu>
848 SetHistogramBincount<GlobalRangeHistogram<BinCount> >::exec(a, options);
871 template <
unsigned LEVEL,
class GlobalAccumulatorHandle>
872 struct AccumulatorEndImpl
874 typedef typename GlobalAccumulatorHandle::type GlobalAccumulatorType;
876 typedef AccumulatorEnd Tag;
877 typedef void value_type;
878 typedef bool result_type;
879 typedef BitArray<LEVEL> AccumulatorFlags;
881 static const unsigned int workInPass = 0;
882 static const int index = -1;
883 static const unsigned level = LEVEL;
885 AccumulatorFlags active_accumulators_;
886 mutable AccumulatorFlags is_dirty_;
887 GlobalAccumulatorHandle globalAccumulator_;
889 template <
class GlobalAccumulator>
890 void setGlobalAccumulator(GlobalAccumulator
const * a)
892 globalAccumulator_.pointer_ = a;
895 static std::string name()
897 return "AccumulatorEnd (internal)";
900 bool operator()()
const {
return false; }
901 bool get()
const {
return false; }
903 template <
unsigned,
class U>
907 template <
unsigned,
class U>
908 void pass(U
const &,
double)
912 void mergeImpl(U
const &)
916 void resize(U
const &)
920 void setCoordinateOffsetImpl(U
const &)
931 template <
class Flags>
932 static void activateImpl(Flags &)
935 template <
class Accu,
class Flags1,
class Flags2>
936 static void activateImpl(Flags1 &, Flags2 &)
939 template <
class Flags>
940 static bool isActiveImpl(Flags
const &)
948 static unsigned int passesRequired()
953 static unsigned int passesRequired(AccumulatorFlags
const &)
960 active_accumulators_.clear();
965 void setDirtyImpl()
const 967 is_dirty_.template set<which>();
971 void setCleanImpl()
const 973 is_dirty_.template reset<which>();
977 bool isDirtyImpl()
const 979 return is_dirty_.template test<which>();
984 template <
class A,
unsigned CurrentPass,
bool allowRuntimeActivation,
unsigned WorkPass=A::workInPass>
988 static void exec(A & a, T
const & t)
992 static void exec(A & a, T
const & t,
double weight)
996 template <
class A,
unsigned CurrentPass>
997 struct DecoratorImpl<A, CurrentPass, false, CurrentPass>
1000 static void exec(A & a, T
const & t)
1006 static void exec(A & a, T
const & t,
double weight)
1008 a.update(t, weight);
1011 static typename A::result_type
get(A
const & a)
1016 static void mergeImpl(A & a, A
const & o)
1022 static void resize(A & a, T
const & t)
1029 ApplyHistogramOptions<typename A::Tag>::exec(a, options);
1032 static unsigned int passesRequired()
1034 static const unsigned int A_workInPass = A::workInPass;
1035 return std::max(A_workInPass, A::InternalBaseType::passesRequired());
1039 template <
class A,
unsigned CurrentPass>
1040 struct DecoratorImpl<A, CurrentPass, true, CurrentPass>
1044 return A::isActiveImpl(getAccumulator<AccumulatorEnd>(a).active_accumulators_);
1048 static void exec(A & a, T
const & t)
1055 static void exec(A & a, T
const & t,
double weight)
1058 a.update(t, weight);
1061 static typename A::result_type
get(A
const & a)
1065 std::string message = std::string(
"get(accumulator): attempt to access inactive statistic '") +
1066 A::Tag::name() +
"'.";
1067 vigra_precondition(
false, message);
1072 static void mergeImpl(A & a, A
const & o)
1079 static void resize(A & a, T
const & t)
1088 ApplyHistogramOptions<typename A::Tag>::exec(a, options);
1091 template <
class ActiveFlags>
1092 static unsigned int passesRequired(ActiveFlags
const & flags)
1094 static const unsigned int A_workInPass = A::workInPass;
1095 return A::isActiveImpl(flags)
1096 ? std::max(A_workInPass, A::InternalBaseType::passesRequired(flags))
1097 : A::InternalBaseType::passesRequired(flags);
1103 template <
class T,
class Shape>
1104 void reshapeImpl(T &, Shape
const &)
1107 template <
class T,
class Shape,
class Initial>
1108 void reshapeImpl(T &, Shape
const &, Initial
const & = T())
1111 template <
unsigned int N,
class T,
class Alloc,
class Shape>
1117 template <
class T,
class Alloc,
class Shape>
1118 void reshapeImpl(Matrix<T, Alloc> & a, Shape
const & s, T
const & initial = T())
1120 Matrix<T, Alloc>(s, initial).swap(a);
1123 template <
class T,
class U>
1124 void copyShapeImpl(T
const &, U
const &)
1127 template <
unsigned int N,
class T,
class Alloc,
class U>
1130 to.reshape(from.shape());
1133 template <
class T,
class Alloc,
class U>
1134 void copyShapeImpl(Matrix<T, Alloc>
const & from, U & to)
1136 to.reshape(from.shape());
1139 template <
class T,
class U>
1140 bool hasDataImpl(T
const &)
1145 template <
unsigned int N,
class T,
class Str
ide>
1152 template <
unsigned int N,
class T,
class Str
ide>
1159 template <
class T,
int N>
1166 template <
class T,
class NEXT>
1173 #define VIGRA_SHAPE_OF(type) \ 1180 VIGRA_SHAPE_OF(
unsigned char)
1181 VIGRA_SHAPE_OF(
signed char)
1182 VIGRA_SHAPE_OF(
unsigned short)
1183 VIGRA_SHAPE_OF(
short)
1184 VIGRA_SHAPE_OF(
unsigned int)
1186 VIGRA_SHAPE_OF(
unsigned long)
1187 VIGRA_SHAPE_OF(
long)
1188 VIGRA_SHAPE_OF(
unsigned long long)
1189 VIGRA_SHAPE_OF(
long long)
1190 VIGRA_SHAPE_OF(
float)
1191 VIGRA_SHAPE_OF(
double)
1192 VIGRA_SHAPE_OF(
long double)
1194 #undef VIGRA_SHAPE_OF 1203 template <
class T,
class GlobalAccumulators,
class RegionAccumulators>
1204 struct LabelDispatch
1206 typedef LabelDispatchTag Tag;
1207 typedef GlobalAccumulators GlobalAccumulatorChain;
1208 typedef RegionAccumulators RegionAccumulatorChain;
1209 typedef typename LookupTag<AccumulatorEnd, RegionAccumulatorChain>::type::AccumulatorFlags ActiveFlagsType;
1212 typedef LabelDispatch type;
1213 typedef LabelDispatch & reference;
1214 typedef LabelDispatch
const & const_reference;
1215 typedef GlobalAccumulatorChain InternalBaseType;
1217 typedef T
const & argument_type;
1218 typedef argument_type first_argument_type;
1219 typedef double second_argument_type;
1220 typedef RegionAccumulatorChain & result_type;
1222 static const int index = GlobalAccumulatorChain::index + 1;
1224 template <
class IndexDefinition,
class TagFound=
typename IndexDefinition::Tag>
1225 struct CoordIndexSelector
1227 static const int value = 0;
1230 template <
class IndexDefinition>
1231 struct CoordIndexSelector<IndexDefinition, CoordArgTag>
1233 static const int value = IndexDefinition::value;
1236 static const int coordIndex = CoordIndexSelector<typename LookupTag<CoordArgTag, GlobalAccumulatorChain>::type>::value;
1237 static const int coordSize = CoupledHandleCast<coordIndex, T>::type::value_type::static_size;
1240 GlobalAccumulatorChain next_;
1241 RegionAccumulatorArray regions_;
1244 ActiveFlagsType active_region_accumulators_;
1245 CoordinateType coordinateOffset_;
1247 template <
class IndexDefinition,
class TagFound=
typename IndexDefinition::Tag>
1248 struct LabelIndexSelector
1250 static const int value = 2;
1252 template <
class U,
class NEXT>
1259 template <
class IndexDefinition>
1260 struct LabelIndexSelector<IndexDefinition, LabelArgTag>
1262 static const int value = IndexDefinition::value;
1264 template <
class U,
class NEXT>
1271 template <
class TAG>
1274 typedef typename LookupTag<TAG, type>::type TargetAccumulator;
1276 static void activate(GlobalAccumulatorChain & globals, RegionAccumulatorArray & regions,
1277 ActiveFlagsType & flags)
1279 TargetAccumulator::template activateImpl<LabelDispatch>(
1280 flags, getAccumulator<AccumulatorEnd>(globals).active_accumulators_);
1281 for(
unsigned int k=0; k<regions.size(); ++k)
1282 getAccumulator<AccumulatorEnd>(regions[k]).active_accumulators_ = flags;
1285 static bool isActive(GlobalAccumulatorChain
const &, ActiveFlagsType
const & flags)
1287 return TargetAccumulator::isActiveImpl(flags);
1291 template <
class TAG>
1292 struct ActivateImpl<Global<TAG> >
1294 static void activate(GlobalAccumulatorChain & globals, RegionAccumulatorArray &, ActiveFlagsType &)
1296 LookupTag<TAG, GlobalAccumulatorChain>::type::activateImpl(getAccumulator<AccumulatorEnd>(globals).active_accumulators_);
1299 static bool isActive(GlobalAccumulatorChain
const & globals, ActiveFlagsType
const &)
1301 return LookupTag<TAG, GlobalAccumulatorChain>::type::isActiveImpl(getAccumulator<AccumulatorEnd>(globals).active_accumulators_);
1305 template <
int INDEX>
1306 struct ActivateImpl<LabelArg<INDEX> >
1308 static void activate(GlobalAccumulatorChain &, RegionAccumulatorArray &, ActiveFlagsType &)
1311 static bool isActive(GlobalAccumulatorChain
const & globals, ActiveFlagsType
const &)
1313 return getAccumulator<LabelArg<INDEX> >(globals).
isActive();
1317 typedef typename LookupTag<LabelArgTag, GlobalAccumulatorChain>::type FindLabelIndex;
1322 region_histogram_options_(),
1324 active_region_accumulators_()
1327 LabelDispatch(LabelDispatch
const & o)
1329 regions_(o.regions_),
1330 region_histogram_options_(o.region_histogram_options_),
1331 ignore_label_(o.ignore_label_),
1332 active_region_accumulators_(o.active_region_accumulators_)
1334 for(
unsigned int k=0; k<regions_.size(); ++k)
1336 getAccumulator<AccumulatorEnd>(regions_[k]).setGlobalAccumulator(&next_);
1345 void setMaxRegionLabel(
unsigned maxlabel)
1349 unsigned int oldSize = regions_.size();
1350 regions_.resize(maxlabel + 1);
1351 for(
unsigned int k=oldSize; k<regions_.size(); ++k)
1353 getAccumulator<AccumulatorEnd>(regions_[k]).setGlobalAccumulator(&next_);
1354 getAccumulator<AccumulatorEnd>(regions_[k]).active_accumulators_ = active_region_accumulators_;
1355 regions_[k].applyHistogramOptions(region_histogram_options_);
1356 regions_[k].setCoordinateOffsetImpl(coordinateOffset_);
1367 applyHistogramOptions(options, options);
1372 region_histogram_options_ = regionoptions;
1373 for(
unsigned int k=0; k<regions_.size(); ++k)
1375 regions_[k].applyHistogramOptions(region_histogram_options_);
1377 next_.applyHistogramOptions(globaloptions);
1380 void setCoordinateOffsetImpl(CoordinateType
const & offset)
1382 coordinateOffset_ = offset;
1383 for(
unsigned int k=0; k<regions_.size(); ++k)
1385 regions_[k].setCoordinateOffsetImpl(coordinateOffset_);
1387 next_.setCoordinateOffsetImpl(coordinateOffset_);
1391 void resize(U
const & t)
1393 if(regions_.size() == 0)
1395 static const int labelIndex = LabelIndexSelector<FindLabelIndex>::value;
1396 typedef typename CoupledHandleCast<labelIndex, T>::type LabelHandle;
1397 typedef typename LabelHandle::value_type LabelType;
1399 LabelArray labelArray(t.shape(), cast<labelIndex>(t).strides(),
const_cast<LabelType *
>(cast<labelIndex>(t).ptr()));
1401 LabelType minimum, maximum;
1402 labelArray.minmax(&minimum, &maximum);
1403 setMaxRegionLabel(maximum);
1407 for(
unsigned int k=0; k<regions_.size(); ++k)
1408 regions_[k].resize(t);
1411 template <
unsigned N>
1412 void pass(T
const & t)
1414 if(LabelIndexSelector<FindLabelIndex>::exec(t) != ignore_label_)
1416 next_.template pass<N>(t);
1417 regions_[LabelIndexSelector<FindLabelIndex>::exec(t)].template pass<N>(t);
1421 template <
unsigned N>
1422 void pass(T
const & t,
double weight)
1424 if(LabelIndexSelector<FindLabelIndex>::exec(t) != ignore_label_)
1426 next_.template pass<N>(t, weight);
1427 regions_[LabelIndexSelector<FindLabelIndex>::exec(t)].template pass<N>(t, weight);
1431 static unsigned int passesRequired()
1433 return std::max(GlobalAccumulatorChain::passesRequired(), RegionAccumulatorChain::passesRequired());
1436 unsigned int passesRequiredDynamic()
const 1438 return std::max(GlobalAccumulatorChain::passesRequired(getAccumulator<AccumulatorEnd>(next_).active_accumulators_),
1439 RegionAccumulatorChain::passesRequired(active_region_accumulators_));
1446 active_region_accumulators_.clear();
1447 RegionAccumulatorArray().swap(regions_);
1453 template <
class TAG>
1456 ActivateImpl<TAG>::activate(next_, regions_, active_region_accumulators_);
1461 getAccumulator<AccumulatorEnd>(next_).active_accumulators_.set();
1462 active_region_accumulators_.set();
1463 for(
unsigned int k=0; k<regions_.size(); ++k)
1464 getAccumulator<AccumulatorEnd>(regions_[k]).active_accumulators_.set();
1467 template <
class TAG>
1470 return ActivateImpl<TAG>::isActive(next_, active_region_accumulators_);
1473 void mergeImpl(LabelDispatch
const & o)
1475 for(
unsigned int k=0; k<regions_.size(); ++k)
1476 regions_[k].mergeImpl(o.regions_[k]);
1477 next_.mergeImpl(o.next_);
1480 void mergeImpl(
unsigned i,
unsigned j)
1482 regions_[i].mergeImpl(regions_[j]);
1483 regions_[j].reset();
1484 getAccumulator<AccumulatorEnd>(regions_[j]).active_accumulators_ = active_region_accumulators_;
1487 template <
class ArrayLike>
1488 void mergeImpl(LabelDispatch
const & o, ArrayLike
const & labelMapping)
1490 MultiArrayIndex newMaxLabel = std::max<MultiArrayIndex>(maxRegionLabel(), *
argMax(labelMapping.begin(), labelMapping.end()));
1491 setMaxRegionLabel(newMaxLabel);
1492 for(
unsigned int k=0; k<labelMapping.size(); ++k)
1493 regions_[labelMapping[k]].mergeImpl(o.regions_[k]);
1494 next_.mergeImpl(o.next_);
1498 template <
class TargetTag,
class TagList>
1501 template <
class TargetTag,
class HEAD,
class TAIL>
1502 struct FindNextTag<TargetTag, TypeList<HEAD, TAIL> >
1504 typedef typename FindNextTag<TargetTag, TAIL>::type type;
1507 template <
class TargetTag,
class TAIL>
1508 struct FindNextTag<TargetTag, TypeList<TargetTag, TAIL> >
1510 typedef typename TAIL::Head type;
1513 template <
class TargetTag>
1514 struct FindNextTag<TargetTag, TypeList<TargetTag, void> >
1519 template <
class TargetTag>
1520 struct FindNextTag<TargetTag, void>
1526 template <
class TAG,
class CONFIG,
unsigned LEVEL=0>
1527 struct AccumulatorFactory
1529 typedef typename FindNextTag<TAG, typename CONFIG::TagList>::type NextTag;
1530 typedef typename AccumulatorFactory<NextTag, CONFIG, LEVEL+1>::type NextType;
1531 typedef typename CONFIG::InputType InputType;
1542 template <
class T,
class NEXT>
1543 struct ConfigureTag<CoupledHandle<T, NEXT> >
1545 typedef typename StandardizeTag<DataFromHandle<TAG> >::type WrappedTag;
1546 typedef typename IfBool<(!HasModifierPriority<WrappedTag, WeightingPriority>::value && ShouldBeWeighted<WrappedTag>::value),
1550 typedef typename ConfigureTag<InputType>::type UseTag;
1554 struct AccumulatorBase
1556 typedef AccumulatorBase ThisType;
1558 typedef NextType InternalBaseType;
1559 typedef InputType input_type;
1560 typedef input_type
const & argument_type;
1561 typedef argument_type first_argument_type;
1562 typedef double second_argument_type;
1563 typedef void result_type;
1565 static const unsigned int workInPass = 1;
1566 static const int index = InternalBaseType::index + 1;
1568 InternalBaseType next_;
1570 static std::string name()
1575 template <
class ActiveFlags>
1576 static void activateImpl(ActiveFlags & flags)
1578 flags.template set<index>();
1579 typedef typename StandardizeDependencies<Tag>::type StdDeps;
1580 acc_detail::ActivateDependencies<StdDeps>::template exec<ThisType>(flags);
1583 template <
class Accu,
class ActiveFlags,
class GlobalFlags>
1584 static void activateImpl(ActiveFlags & flags, GlobalFlags & gflags)
1586 flags.template set<index>();
1587 typedef typename StandardizeDependencies<Tag>::type StdDeps;
1588 acc_detail::ActivateDependencies<StdDeps>::template exec<Accu>(flags, gflags);
1591 template <
class ActiveFlags>
1592 static bool isActiveImpl(ActiveFlags & flags)
1594 return flags.template test<index>();
1597 void setDirty()
const 1599 next_.template setDirtyImpl<index>();
1602 template <
int INDEX>
1603 void setDirtyImpl()
const 1605 next_.template setDirtyImpl<INDEX>();
1608 void setClean()
const 1610 next_.template setCleanImpl<index>();
1613 template <
int INDEX>
1614 void setCleanImpl()
const 1616 next_.template setCleanImpl<INDEX>();
1619 bool isDirty()
const 1621 return next_.template isDirtyImpl<index>();
1624 template <
int INDEX>
1625 bool isDirtyImpl()
const 1627 return next_.template isDirtyImpl<INDEX>();
1633 template <
class Shape>
1634 void setCoordinateOffset(Shape
const &)
1637 template <
class Shape>
1638 void reshape(Shape
const &)
1645 void update(U
const &)
1649 void update(U
const &,
double)
1652 template <
class TargetTag>
1653 typename LookupDependency<TargetTag, ThisType>::result_type
1654 call_getDependency()
const 1656 return getDependency<TargetTag>(*this);
1661 typedef typename UseTag::template Impl<InputType, AccumulatorBase> AccumulatorImpl;
1668 :
public AccumulatorImpl
1670 typedef Accumulator type;
1671 typedef Accumulator & reference;
1672 typedef Accumulator
const & const_reference;
1673 typedef AccumulatorImpl A;
1675 static const unsigned int workInPass = A::workInPass;
1676 static const bool allowRuntimeActivation = CONFIG::allowRuntimeActivation;
1679 void resize(T
const & t)
1681 this->next_.resize(t);
1682 DecoratorImpl<Accumulator, workInPass, allowRuntimeActivation>::resize(*
this, t);
1687 this->next_.reset();
1691 typename A::result_type
get()
const 1696 template <
unsigned N,
class T>
1697 void pass(T
const & t)
1699 this->next_.template pass<N>(t);
1700 DecoratorImpl<Accumulator, N, allowRuntimeActivation>::exec(*
this, t);
1703 template <
unsigned N,
class T>
1704 void pass(T
const & t,
double weight)
1706 this->next_.template pass<N>(t, weight);
1707 DecoratorImpl<Accumulator, N, allowRuntimeActivation>::exec(*
this, t, weight);
1710 void mergeImpl(Accumulator
const & o)
1712 DecoratorImpl<Accumulator, Accumulator::workInPass, allowRuntimeActivation>::mergeImpl(*
this, o);
1713 this->next_.mergeImpl(o.next_);
1718 DecoratorImpl<Accumulator, workInPass, allowRuntimeActivation>::applyHistogramOptions(*
this, options);
1719 this->next_.applyHistogramOptions(options);
1722 template <
class SHAPE>
1723 void setCoordinateOffsetImpl(SHAPE
const & offset)
1725 this->setCoordinateOffset(offset);
1726 this->next_.setCoordinateOffsetImpl(offset);
1729 static unsigned int passesRequired()
1731 return DecoratorImpl<Accumulator, workInPass, allowRuntimeActivation>::passesRequired();
1734 template <
class ActiveFlags>
1735 static unsigned int passesRequired(ActiveFlags
const & flags)
1737 return DecoratorImpl<Accumulator, workInPass, allowRuntimeActivation>::passesRequired(flags);
1741 typedef Accumulator type;
1744 template <
class CONFIG,
unsigned LEVEL>
1745 struct AccumulatorFactory<void, CONFIG, LEVEL>
1747 typedef AccumulatorEndImpl<LEVEL, typename CONFIG::GlobalAccumulatorHandle> type;
1750 struct InvalidGlobalAccumulatorHandle
1752 typedef Error__Global_statistics_are_only_defined_for_AccumulatorChainArray type;
1754 InvalidGlobalAccumulatorHandle()
1758 type
const * pointer_;
1764 template <
class T,
class Selected,
bool dynamic=false,
class GlobalHandle=Inval
idGlobalAccumulatorHandle>
1765 struct ConfigureAccumulatorChain
1767 :
public ConfigureAccumulatorChain<T, typename AddDependencies<typename Selected::type>::type, dynamic>
1771 template <
class T,
class HEAD,
class TAIL,
bool dynamic,
class GlobalHandle>
1772 struct ConfigureAccumulatorChain<T, TypeList<HEAD, TAIL>, dynamic, GlobalHandle>
1774 typedef TypeList<HEAD, TAIL> TagList;
1775 typedef T InputType;
1776 static const bool allowRuntimeActivation = dynamic;
1777 typedef GlobalHandle GlobalAccumulatorHandle;
1779 typedef typename AccumulatorFactory<HEAD, ConfigureAccumulatorChain>::type type;
1782 template <
class T,
class Selected,
bool dynamic=false>
1783 struct ConfigureAccumulatorChainArray
1785 :
public ConfigureAccumulatorChainArray<T, typename AddDependencies<typename Selected::type>::type, dynamic>
1789 template <
class T,
class HEAD,
class TAIL,
bool dynamic>
1790 struct ConfigureAccumulatorChainArray<T, TypeList<HEAD, TAIL>, dynamic>
1792 typedef TypeList<HEAD, TAIL> TagList;
1793 typedef SeparateGlobalAndRegionTags<TagList> TagSeparator;
1794 typedef typename TagSeparator::GlobalTags GlobalTags;
1795 typedef typename TagSeparator::RegionTags RegionTags;
1796 typedef typename ConfigureAccumulatorChain<T, GlobalTags, dynamic>::type GlobalAccumulatorChain;
1798 struct GlobalAccumulatorHandle
1800 typedef GlobalAccumulatorChain type;
1802 GlobalAccumulatorHandle()
1806 type
const * pointer_;
1809 typedef typename ConfigureAccumulatorChain<T, RegionTags, dynamic, GlobalAccumulatorHandle>::type RegionAccumulatorChain;
1811 typedef LabelDispatch<T, GlobalAccumulatorChain, RegionAccumulatorChain> type;
1823 template <
class T,
class NEXT>
1824 class AccumulatorChainImpl
1827 typedef NEXT InternalBaseType;
1828 typedef AccumulatorBegin Tag;
1829 typedef typename InternalBaseType::argument_type argument_type;
1830 typedef typename InternalBaseType::first_argument_type first_argument_type;
1831 typedef typename InternalBaseType::second_argument_type second_argument_type;
1832 typedef void value_type;
1833 typedef typename InternalBaseType::result_type result_type;
1835 static const int staticSize = InternalBaseType::index;
1837 InternalBaseType next_;
1841 unsigned int current_pass_;
1843 AccumulatorChainImpl()
1851 next_.applyHistogramOptions(options);
1859 next_.applyHistogramOptions(regionoptions, globaloptions);
1868 template <
class SHAPE>
1869 void setCoordinateOffset(SHAPE
const & offset)
1871 next_.setCoordinateOffsetImpl(offset);
1876 void reset(
unsigned int reset_to_pass = 0)
1878 current_pass_ = reset_to_pass;
1879 if(reset_to_pass == 0)
1883 template <
unsigned N>
1884 void update(T
const & t)
1886 if(current_pass_ == N)
1888 next_.template pass<N>(t);
1890 else if(current_pass_ < N)
1894 next_.resize(acc_detail::shapeOf(t));
1895 next_.template pass<N>(t);
1899 std::string message(
"AccumulatorChain::update(): cannot return to pass ");
1900 message << N <<
" after working on pass " << current_pass_ <<
".";
1901 vigra_precondition(
false, message);
1905 template <
unsigned N>
1906 void update(T
const & t,
double weight)
1908 if(current_pass_ == N)
1910 next_.template pass<N>(t, weight);
1912 else if(current_pass_ < N)
1916 next_.resize(acc_detail::shapeOf(t));
1917 next_.template pass<N>(t, weight);
1921 std::string message(
"AccumulatorChain::update(): cannot return to pass ");
1922 message << N <<
" after working on pass " << current_pass_ <<
".";
1923 vigra_precondition(
false, message);
1929 void operator+=(AccumulatorChainImpl
const & o)
1936 void merge(AccumulatorChainImpl
const & o)
1938 next_.mergeImpl(o.next_);
1941 result_type operator()()
const 1946 void operator()(T
const & t)
1951 void operator()(T
const & t,
double weight)
1953 update<1>(t, weight);
1956 void updatePass2(T
const & t)
1961 void updatePass2(T
const & t,
double weight)
1963 update<2>(t, weight);
1968 void updatePassN(T
const & t,
unsigned int N)
1972 case 1: update<1>(t);
break;
1973 case 2: update<2>(t);
break;
1974 case 3: update<3>(t);
break;
1975 case 4: update<4>(t);
break;
1976 case 5: update<5>(t);
break;
1978 vigra_precondition(
false,
1979 "AccumulatorChain::updatePassN(): 0 < N < 6 required.");
1985 void updatePassN(T
const & t,
double weight,
unsigned int N)
1989 case 1: update<1>(t, weight);
break;
1990 case 2: update<2>(t, weight);
break;
1991 case 3: update<3>(t, weight);
break;
1992 case 4: update<4>(t, weight);
break;
1993 case 5: update<5>(t, weight);
break;
1995 vigra_precondition(
false,
1996 "AccumulatorChain::updatePassN(): 0 < N < 6 required.");
2002 unsigned int passesRequired()
const 2004 return InternalBaseType::passesRequired();
2039 template <
class T,
class Selected,
bool dynamic=false>
2042 :
public AccumulatorChainImpl<T, typename acc_detail::ConfigureAccumulatorChain<T, Selected, dynamic>::type>
2047 typedef typename acc_detail::ConfigureAccumulatorChain<T, Selected, dynamic>::TagList AccumulatorTags;
2051 template <
class U,
int N>
2054 vigra_precondition(this->current_pass_ == 0,
2055 "AccumulatorChain::reshape(): cannot reshape after seeing data. Call AccumulatorChain::reset() first.");
2056 this->next_.resize(s);
2057 this->current_pass_ = 1;
2069 #ifdef DOXYGEN // hide AccumulatorChainImpl from documentation 2081 template <
class SHAPE>
2082 void setCoordinateOffset(SHAPE
const & offset);
2085 void reset(
unsigned int reset_to_pass = 0);
2088 void operator+=(AccumulatorChainImpl
const & o);
2092 void merge(AccumulatorChainImpl
const & o);
2096 void updatePassN(T
const & t,
unsigned int N);
2100 void updatePassN(T
const & t,
double weight,
unsigned int N);
2104 unsigned int passesRequired()
const;
2112 acc_detail::CollectAccumulatorNames<AccumulatorTags>::exec(n);
2118 template <
unsigned int N,
class T1,
class T2,
class T3,
class T4,
class T5,
class Selected,
bool dynamic>
2119 class AccumulatorChain<CoupledArrays<N, T1, T2, T3, T4, T5>, Selected, dynamic>
2120 :
public AccumulatorChain<typename CoupledArrays<N, T1, T2, T3, T4, T5>::HandleType, Selected, dynamic>
2153 template <
class T,
class Selected>
2159 typedef typename DynamicAccumulatorChain::AccumulatorTags AccumulatorTags;
2165 vigra_precondition(activateImpl(tag),
2166 std::string(
"DynamicAccumulatorChain::activate(): Tag '") + tag +
"' not found.");
2171 template <
class TAG>
2174 LookupTag<TAG, DynamicAccumulatorChain>::type::activateImpl(getAccumulator<AccumulatorEnd>(*this).active_accumulators_);
2181 getAccumulator<AccumulatorEnd>(*this).active_accumulators_.set();
2187 acc_detail::TagIsActive_Visitor v;
2188 vigra_precondition(isActiveImpl(tag, v),
2189 std::string(
"DynamicAccumulatorChain::isActive(): Tag '") + tag +
"' not found.");
2195 template <
class TAG>
2198 return LookupTag<TAG, DynamicAccumulatorChain>::type::isActiveImpl(getAccumulator<AccumulatorEnd>(*this).active_accumulators_);
2216 return InternalBaseType::passesRequired(getAccumulator<AccumulatorEnd>(*this).active_accumulators_);
2221 bool activateImpl(std::string tag)
2223 return acc_detail::ApplyVisitorToTag<AccumulatorTags>::exec(*
this,
2224 normalizeString(tag), acc_detail::ActivateTag_Visitor());
2227 bool isActiveImpl(std::string tag, acc_detail::TagIsActive_Visitor & v)
const 2229 return acc_detail::ApplyVisitorToTag<AccumulatorTags>::exec(*
this, normalizeString(tag), v);
2233 template <
unsigned int N,
class T1,
class T2,
class T3,
class T4,
class T5,
class Selected>
2260 template <
class T,
class Selected,
bool dynamic=false>
2263 :
public AccumulatorChainImpl<T, typename acc_detail::ConfigureAccumulatorChainArray<T, Selected, dynamic>::type>
2267 typedef typename acc_detail::ConfigureAccumulatorChainArray<T, Selected, dynamic> Creator;
2268 typedef typename Creator::TagList AccumulatorTags;
2269 typedef typename Creator::GlobalTags GlobalTags;
2270 typedef typename Creator::RegionTags RegionTags;
2276 this->next_.ignoreLabel(l);
2283 this->next_.setMaxRegionLabel(label);
2290 return this->next_.maxRegionLabel();
2297 return this->next_.regions_.size();
2311 vigra_precondition(i <= maxRegionLabel() && j <= maxRegionLabel(),
2312 "AccumulatorChainArray::merge(): region labels out of range.");
2313 this->next_.mergeImpl(i, j);
2320 if(maxRegionLabel() == -1)
2323 "AccumulatorChainArray::merge(): maxRegionLabel must be equal.");
2324 this->next_.mergeImpl(o.next_);
2329 template <
class ArrayLike>
2332 vigra_precondition(labelMapping.size() == o.
regionCount(),
2333 "AccumulatorChainArray::merge(): labelMapping.size() must match regionCount() of RHS.");
2334 this->next_.mergeImpl(o.next_, labelMapping);
2346 #ifdef DOXYGEN // hide AccumulatorChainImpl from documentation 2357 template <
class SHAPE>
2358 void setCoordinateOffset(SHAPE
const & offset)
2361 void reset(
unsigned int reset_to_pass = 0);
2364 void operator+=(AccumulatorChainImpl
const & o);
2367 void updatePassN(T
const & t,
unsigned int N);
2370 void updatePassN(T
const & t,
double weight,
unsigned int N);
2378 acc_detail::CollectAccumulatorNames<AccumulatorTags>::exec(n);
2384 template <
unsigned int N,
class T1,
class T2,
class T3,
class T4,
class T5,
class Selected,
bool dynamic>
2386 :
public AccumulatorChainArray<typename CoupledArrays<N, T1, T2, T3, T4, T5>::HandleType, Selected, dynamic>
2410 template <
class T,
class Selected>
2415 typedef typename DynamicAccumulatorChainArray::AccumulatorTags AccumulatorTags;
2420 vigra_precondition(activateImpl(tag),
2421 std::string(
"DynamicAccumulatorChainArray::activate(): Tag '") + tag +
"' not found.");
2425 template <
class TAG>
2428 this->next_.template activate<TAG>();
2434 this->next_.activateAll();
2441 acc_detail::TagIsActive_Visitor v;
2442 vigra_precondition(isActiveImpl(tag, v),
2443 std::string(
"DynamicAccumulatorChainArray::isActive(): Tag '") + tag +
"' not found.");
2449 template <
class TAG>
2452 return this->next_.template isActive<TAG>();
2468 return this->next_.passesRequiredDynamic();
2473 bool activateImpl(std::string tag)
2475 return acc_detail::ApplyVisitorToTag<AccumulatorTags>::exec(this->next_,
2476 normalizeString(tag), acc_detail::ActivateTag_Visitor());
2479 bool isActiveImpl(std::string tag, acc_detail::TagIsActive_Visitor & v)
const 2481 return acc_detail::ApplyVisitorToTag<AccumulatorTags>::exec(this->next_, normalizeString(tag), v);
2485 template <
unsigned int N,
class T1,
class T2,
class T3,
class T4,
class T5,
class Selected>
2496 template <
class TAG>
2497 struct Error__Attempt_to_access_inactive_statistic;
2499 namespace acc_detail {
2504 template <
class TAG,
class A,
class FromTag=
typename A::Tag>
2505 struct LookupTagImpl
2507 :
public LookupTagImpl<TAG, typename A::InternalBaseType>
2512 template <
class TAG,
class A,
class FromTag>
2513 struct LookupTagImpl<TAG, A const, FromTag>
2514 :
public LookupTagImpl<TAG, A>
2516 typedef typename LookupTagImpl<TAG, A>::type
const & reference;
2517 typedef typename LookupTagImpl<TAG, A>::type
const * pointer;
2521 template <
class TAG,
class A>
2522 struct LookupTagImpl<TAG, A, TAG>
2526 typedef A & reference;
2527 typedef A * pointer;
2528 typedef typename A::value_type value_type;
2529 typedef typename A::result_type result_type;
2533 template <
class TAG,
class A>
2534 struct LookupTagImpl<TAG, A const, TAG>
2535 :
public LookupTagImpl<TAG, A, TAG>
2537 typedef typename LookupTagImpl<TAG, A, TAG>::type
const & reference;
2538 typedef typename LookupTagImpl<TAG, A, TAG>::type
const * pointer;
2543 template <
class TAG,
class A>
2544 struct LookupTagImpl<TAG, A, AccumulatorEnd>
2548 typedef A & reference;
2549 typedef A * pointer;
2550 typedef Error__Attempt_to_access_inactive_statistic<TAG> value_type;
2551 typedef Error__Attempt_to_access_inactive_statistic<TAG> result_type;
2556 struct LookupTagImpl<AccumulatorEnd, A, AccumulatorEnd>
2558 typedef AccumulatorEnd Tag;
2560 typedef A & reference;
2561 typedef A * pointer;
2562 typedef void value_type;
2563 typedef void result_type;
2569 template <
class TAG,
class A>
2570 struct LookupTagImpl<Global<TAG>, A, AccumulatorEnd>
2571 :
public LookupTagImpl<TAG, typename A::GlobalAccumulatorType>
2578 template <
class TAG,
class A>
2579 struct LookupTagImpl<TAG, A, LabelDispatchTag>
2580 :
public LookupTagImpl<TAG, typename A::RegionAccumulatorChain>
2586 template <
class TAG,
class A>
2587 struct LookupTagImpl<Global<TAG>, A, LabelDispatchTag>
2588 :
public LookupTagImpl<TAG, typename A::GlobalAccumulatorChain>
2595 struct LookupTagImpl<LabelDispatchTag, A, LabelDispatchTag>
2597 typedef LabelDispatchTag Tag;
2599 typedef A & reference;
2600 typedef A * pointer;
2601 typedef void value_type;
2602 typedef void result_type;
2608 template <
class Tag,
class A>
2610 :
public acc_detail::LookupTagImpl<typename StandardizeTag<Tag>::type, A>
2617 template <
class Tag,
class A,
class TargetTag>
2618 struct LookupDependency
2619 :
public acc_detail::LookupTagImpl<
2620 typename TransferModifiers<TargetTag, typename StandardizeTag<Tag>::type>::type, A>
2624 namespace acc_detail {
2628 template <
class Tag,
class FromTag,
class reference>
2632 static reference exec(A & a)
2634 return CastImpl<Tag, typename A::InternalBaseType::Tag, reference>::exec(a.next_);
2640 return CastImpl<Tag, typename A::InternalBaseType::Tag, reference>::exec(a.next_, label);
2644 template <
class Tag,
class reference>
2645 struct CastImpl<Tag, Tag, reference>
2648 static reference exec(A & a)
2650 return const_cast<reference
>(a);
2656 vigra_precondition(
false,
2657 "getAccumulator(): region accumulators can only be queried for AccumulatorChainArray.");
2662 template <
class Tag,
class reference>
2663 struct CastImpl<Tag, AccumulatorEnd, reference>
2666 static reference exec(A & a)
2678 template <
class Tag,
class reference>
2679 struct CastImpl<Global<Tag>, AccumulatorEnd, reference>
2682 static reference exec(A & a)
2684 return CastImpl<Tag, typename A::GlobalAccumulatorType::Tag, reference>::exec(*a.globalAccumulator_.pointer_);
2688 template <
class reference>
2689 struct CastImpl<AccumulatorEnd, AccumulatorEnd, reference>
2692 static reference exec(A & a)
2704 template <
class Tag,
class reference>
2705 struct CastImpl<Tag, LabelDispatchTag, reference>
2708 static reference exec(A & a)
2710 vigra_precondition(
false,
2711 "getAccumulator(): a region label is required when a region accumulator is queried.");
2712 return CastImpl<Tag, typename A::RegionAccumulatorChain::Tag, reference>::exec(a.regions_[0]);
2718 return CastImpl<Tag, typename A::RegionAccumulatorChain::Tag, reference>::exec(a.regions_[label]);
2722 template <
class Tag,
class reference>
2723 struct CastImpl<Global<Tag>, LabelDispatchTag, reference>
2726 static reference exec(A & a)
2728 return CastImpl<Tag, typename A::GlobalAccumulatorChain::Tag, reference>::exec(a.next_);
2732 template <
class reference>
2733 struct CastImpl<LabelDispatchTag, LabelDispatchTag, reference>
2736 static reference exec(A & a)
2769 template <
class TAG,
class A>
2770 inline typename LookupTag<TAG, A>::reference
2773 typedef typename LookupTag<TAG, A>::Tag StandardizedTag;
2774 typedef typename LookupTag<TAG, A>::reference reference;
2775 return acc_detail::CastImpl<StandardizedTag, typename A::Tag, reference>::exec(a);
2781 template <
class TAG,
class A>
2782 inline typename LookupTag<TAG, A>::reference
2785 typedef typename LookupTag<TAG, A>::Tag StandardizedTag;
2786 typedef typename LookupTag<TAG, A>::reference reference;
2787 return acc_detail::CastImpl<StandardizedTag, typename A::Tag, reference>::exec(a, label);
2801 template <
class TAG,
class A>
2802 inline typename LookupTag<TAG, A>::result_type
2805 return getAccumulator<TAG>(a).
get();
2829 template <
class TAG,
class A>
2830 inline typename LookupTag<TAG, A>::result_type
2833 return getAccumulator<TAG>(a, label).
get();
2840 template <
class TAG,
class A>
2841 inline typename LookupDependency<TAG, A>::result_type
2842 getDependency(A
const & a)
2844 typedef typename LookupDependency<TAG, A>::Tag StandardizedTag;
2845 typedef typename LookupDependency<TAG, A>::reference reference;
2846 return acc_detail::CastImpl<StandardizedTag, typename A::Tag, reference>::exec(a)();
2853 template <
class Tag,
class A>
2857 a.template activate<Tag>();
2864 template <
class Tag,
class A>
2868 return a.template isActive<Tag>();
2946 template <
class ITERATOR,
class ACCUMULATOR>
2949 for(
unsigned int k=1; k <= a.passesRequired(); ++k)
2950 for(ITERATOR i=start; i < end; ++i)
2951 a.updatePassN(*i, k);
2954 template <
unsigned int N,
class T1,
class S1,
2961 end = start.getEndIterator();
2965 template <
unsigned int N,
class T1,
class S1,
2974 end = start.getEndIterator();
2978 template <
unsigned int N,
class T1,
class S1,
2989 end = start.getEndIterator();
2993 template <
unsigned int N,
class T1,
class S1,
3006 end = start.getEndIterator();
3010 template <
unsigned int N,
class T1,
class S1,
3025 end = start.getEndIterator();
3036 struct AccumulatorResultTraits
3039 typedef T element_type;
3040 typedef double element_promote_type;
3041 typedef T MinmaxType;
3042 typedef element_promote_type SumType;
3043 typedef element_promote_type FlatCovarianceType;
3044 typedef element_promote_type CovarianceType;
3047 template <
class T,
int N>
3048 struct AccumulatorResultTraits<TinyVector<T, N> >
3051 typedef T element_type;
3052 typedef double element_promote_type;
3055 typedef TinyVector<element_promote_type, N*(N+1)/2> FlatCovarianceType;
3056 typedef Matrix<element_promote_type> CovarianceType;
3060 template <
class T,
unsigned int RED_IDX,
unsigned int GREEN_IDX,
unsigned int BLUE_IDX>
3061 struct AccumulatorResultTraits<RGBValue<T, RED_IDX, GREEN_IDX, BLUE_IDX> >
3064 typedef T element_type;
3065 typedef double element_promote_type;
3068 typedef TinyVector<element_promote_type, 3*(3+1)/2> FlatCovarianceType;
3069 typedef Matrix<element_promote_type> CovarianceType;
3074 template <
unsigned int N,
class T,
class Str
ide>
3075 struct AccumulatorResultTraits<MultiArrayView<N, T, Stride> >
3078 typedef T element_type;
3079 typedef double element_promote_type;
3083 typedef Matrix<element_promote_type> CovarianceType;
3086 template <
unsigned int N,
class T,
class Alloc>
3087 struct AccumulatorResultTraits<MultiArray<N, T, Alloc> >
3090 typedef T element_type;
3091 typedef double element_promote_type;
3095 typedef Matrix<element_promote_type> CovarianceType;
3108 template <
class TAG>
3112 typedef typename StandardizeTag<TAG>::type TargetTag;
3113 typedef typename TargetTag::Dependencies Dependencies;
3115 static std::string name()
3117 return std::string(
"Global<") + TargetTag::name() +
" >";
3127 template <
int INDEX>
3133 static std::string name()
3135 return std::string(
"DataArg<") + asString(INDEX) +
"> (internal)";
3140 template <
class T,
class BASE>
3144 typedef DataArgTag Tag;
3145 typedef void value_type;
3146 typedef void result_type;
3148 static const int value = INDEX;
3149 static const unsigned int workInPass = 0;
3154 template <
class TAG>
3155 class DataFromHandle
3158 typedef typename StandardizeTag<TAG>::type TargetTag;
3159 typedef typename TargetTag::Dependencies Dependencies;
3161 static std::string name()
3163 return std::string(
"DataFromHandle<") + TargetTag::name() +
" > (internal)";
3168 template <
class IndexDefinition,
class TagFound=
typename IndexDefinition::Tag>
3169 struct DataIndexSelector
3171 static const int value = 1;
3173 template <
class U,
class NEXT>
3174 static typename CoupledHandleCast<value, CoupledHandle<U, NEXT> >::type::const_reference
3177 return vigra::get<value>(t);
3181 template <
class IndexDefinition>
3182 struct DataIndexSelector<IndexDefinition, DataArgTag>
3184 static const int value = IndexDefinition::value;
3186 template <
class U,
class NEXT>
3187 static typename CoupledHandleCast<value, CoupledHandle<U, NEXT> >::type::const_reference
3190 return vigra::get<value>(t);
3194 template <
class T,
class BASE>
3195 struct SelectInputType
3197 typedef typename LookupTag<DataArgTag, BASE>::type FindDataIndex;
3198 typedef DataIndexSelector<FindDataIndex> DataIndex;
3199 typedef typename CoupledHandleCast<DataIndex::value, T>::type::value_type type;
3202 template <
class T,
class BASE>
3204 :
public TargetTag::template Impl<typename SelectInputType<T, BASE>::type, BASE>
3206 typedef SelectInputType<T, BASE> InputTypeSelector;
3207 typedef typename InputTypeSelector::DataIndex DataIndex;
3208 typedef typename InputTypeSelector::type input_type;
3209 typedef input_type
const & argument_type;
3210 typedef argument_type first_argument_type;
3212 typedef typename TargetTag::template Impl<input_type, BASE> ImplType;
3214 using ImplType::reshape;
3216 template <
class U,
class NEXT>
3219 ImplType::reshape(acc_detail::shapeOf(DataIndex::exec(t)));
3222 template <
class U,
class NEXT>
3225 ImplType::update(DataIndex::exec(t));
3228 template <
class U,
class NEXT>
3231 ImplType::update(DataIndex::exec(t), weight);
3240 template <
class TAG>
3244 typedef typename StandardizeTag<TAG>::type TargetTag;
3245 typedef typename TargetTag::Dependencies Dependencies;
3247 static std::string name()
3249 return std::string(
"Coord<") + TargetTag::name() +
" >";
3254 template <
class IndexDefinition,
class TagFound=
typename IndexDefinition::Tag>
3255 struct CoordIndexSelector
3257 static const int value = 0;
3259 template <
class U,
class NEXT>
3260 static typename CoupledHandleCast<value, CoupledHandle<U, NEXT> >::type::const_reference
3263 return vigra::get<value>(t);
3267 template <
class IndexDefinition>
3268 struct CoordIndexSelector<IndexDefinition, CoordArgTag>
3270 static const int value = IndexDefinition::value;
3272 template <
class U,
class NEXT>
3273 static typename CoupledHandleCast<value, CoupledHandle<U, NEXT> >::type::const_reference
3276 return vigra::get<value>(t);
3280 template <
class T,
class BASE>
3281 struct SelectInputType
3283 typedef typename LookupTag<CoordArgTag, BASE>::type FindDataIndex;
3284 typedef CoordIndexSelector<FindDataIndex> CoordIndex;
3285 typedef typename CoupledHandleCast<CoordIndex::value, T>::type::value_type type;
3286 static const int size = type::static_size;
3289 template <
class T,
class BASE>
3291 :
public TargetTag::template Impl<TinyVector<double, SelectInputType<T, BASE>::size>, BASE>
3293 typedef SelectInputType<T, BASE> InputTypeSelector;
3294 typedef typename InputTypeSelector::CoordIndex CoordIndex;
3296 typedef input_type
const & argument_type;
3297 typedef argument_type first_argument_type;
3299 typedef typename TargetTag::template Impl<input_type, BASE> ImplType;
3307 void setCoordinateOffset(input_type
const & offset)
3312 using ImplType::reshape;
3314 template <
class U,
class NEXT>
3317 ImplType::reshape(acc_detail::shapeOf(CoordIndex::exec(t)));
3320 template <
class U,
class NEXT>
3323 ImplType::update(CoordIndex::exec(t)+offset_);
3326 template <
class U,
class NEXT>
3329 ImplType::update(CoordIndex::exec(t)+offset_, weight);
3338 template <
int INDEX>
3344 static std::string name()
3346 return std::string(
"WeightArg<") + asString(INDEX) +
"> (internal)";
3351 template <
class T,
class BASE>
3355 typedef WeightArgTag Tag;
3356 typedef void value_type;
3357 typedef void result_type;
3359 static const int value = INDEX;
3360 static const unsigned int workInPass = 0;
3366 template <
class TAG>
3370 typedef typename StandardizeTag<TAG>::type TargetTag;
3371 typedef typename TargetTag::Dependencies Dependencies;
3373 static std::string name()
3375 return std::string(
"Weighted<") + TargetTag::name() +
" >";
3380 template <
class IndexDefinition,
class TagFound=
typename IndexDefinition::Tag>
3381 struct WeightIndexSelector
3383 template <
class U,
class NEXT>
3390 template <
class IndexDefinition>
3391 struct WeightIndexSelector<IndexDefinition, WeightArgTag>
3393 template <
class U,
class NEXT>
3396 return (
double)get<IndexDefinition::value>(t);
3400 template <
class T,
class BASE>
3402 :
public TargetTag::template Impl<T, BASE>
3404 typedef typename TargetTag::template Impl<T, BASE> ImplType;
3406 typedef typename LookupTag<WeightArgTag, BASE>::type FindWeightIndex;
3408 template <
class U,
class NEXT>
3411 ImplType::update(t, WeightIndexSelector<FindWeightIndex>::exec(t));
3422 static std::string name()
3424 return "Centralize (internal)";
3429 template <
class U,
class BASE>
3433 static const unsigned int workInPass = 2;
3435 typedef typename AccumulatorResultTraits<U>::element_promote_type element_type;
3436 typedef typename AccumulatorResultTraits<U>::SumType value_type;
3437 typedef value_type
const & result_type;
3439 mutable value_type value_;
3447 value_ = element_type();
3450 template <
class Shape>
3451 void reshape(Shape
const & s)
3453 acc_detail::reshapeImpl(value_, s);
3456 void update(U
const & t)
const 3459 value_ = t - getDependency<Mean>(*this);
3462 void update(U
const & t,
double)
const 3467 result_type operator()(U
const & t)
const 3473 result_type operator()()
const 3484 template <
class TAG>
3488 typedef typename StandardizeTag<TAG>::type TargetTag;
3491 static std::string name()
3493 return std::string(
"Central<") + TargetTag::name() +
" >";
3498 template <
class U,
class BASE>
3500 :
public TargetTag::template Impl<typename AccumulatorResultTraits<U>::SumType, BASE>
3502 typedef typename TargetTag::template Impl<typename AccumulatorResultTraits<U>::SumType, BASE> ImplType;
3504 static const unsigned int workInPass = 2;
3508 vigra_precondition(
false,
3509 "Central<...>::operator+=(): not supported.");
3513 void update(T
const & t)
3515 ImplType::update(getDependency<Centralize>(*
this));
3519 void update(T
const & t,
double weight)
3521 ImplType::update(getDependency<Centralize>(*
this), weight);
3564 class PrincipalProjection
3569 static std::string name()
3571 return "PrincipalProjection (internal)";
3576 template <
class U,
class BASE>
3580 static const unsigned int workInPass = 2;
3582 typedef typename AccumulatorResultTraits<U>::element_promote_type element_type;
3583 typedef typename AccumulatorResultTraits<U>::SumType value_type;
3584 typedef value_type
const & result_type;
3586 mutable value_type value_;
3594 value_ = element_type();
3597 template <
class Shape>
3598 void reshape(Shape
const & s)
3600 acc_detail::reshapeImpl(value_, s);
3603 void update(U
const & t)
const 3605 for(
unsigned int k=0; k<t.size(); ++k)
3607 value_[k] = getDependency<Principal<CoordinateSystem> >(*this)(0, k)*getDependency<Centralize>(*
this)[0];
3608 for(
unsigned int d=1; d<t.size(); ++d)
3613 void update(U
const & t,
double)
const 3618 result_type operator()(U
const & t)
const 3620 getAccumulator<Centralize>(*this).update(t);
3625 result_type operator()()
const 3636 template <
class TAG>
3640 typedef typename StandardizeTag<TAG>::type TargetTag;
3643 static std::string name()
3645 return std::string(
"Principal<") + TargetTag::name() +
" >";
3650 template <
class U,
class BASE>
3652 :
public TargetTag::template Impl<typename AccumulatorResultTraits<U>::SumType, BASE>
3654 typedef typename TargetTag::template Impl<typename AccumulatorResultTraits<U>::SumType, BASE> ImplType;
3656 static const unsigned int workInPass = 2;
3660 vigra_precondition(
false,
3661 "Principal<...>::operator+=(): not supported.");
3665 void update(T
const & t)
3667 ImplType::update(getDependency<PrincipalProjection>(*
this));
3671 void update(T
const & t,
double weight)
3673 ImplType::update(getDependency<PrincipalProjection>(*
this), weight);
3710 static std::string name()
3712 return "CoordinateSystem";
3717 template <
class U,
class BASE>
3721 typedef double element_type;
3722 typedef Matrix<double> value_type;
3723 typedef value_type
const & result_type;
3733 value_ = element_type();
3736 template <
class Shape>
3737 void reshape(Shape
const & s)
3739 acc_detail::reshapeImpl(value_, s);
3742 result_type operator()()
const 3749 template <
class BASE,
class T,
3750 class ElementType=
typename AccumulatorResultTraits<T>::element_promote_type,
3751 class SumType=
typename AccumulatorResultTraits<T>::SumType>
3755 typedef ElementType element_type;
3756 typedef SumType value_type;
3757 typedef value_type
const & result_type;
3767 value_ = element_type();
3770 template <
class Shape>
3771 void reshape(Shape
const & s)
3773 acc_detail::reshapeImpl(value_, s);
3781 result_type operator()()
const 3794 static std::string name()
3796 return "PowerSum<0>";
3801 template <
class T,
class BASE>
3803 :
public SumBaseImpl<BASE, T, double, double>
3805 void update(T
const & t)
3810 void update(T
const & t,
double weight)
3812 this->value_ += weight;
3824 static std::string name()
3826 return "PowerSum<1>";
3831 template <
class U,
class BASE>
3833 :
public SumBaseImpl<BASE, U>
3835 void update(U
const & t)
3840 void update(U
const & t,
double weight)
3842 this->value_ += weight*t;
3851 template <
unsigned N>
3857 static std::string name()
3859 return std::string(
"PowerSum<") + asString(N) +
">";
3864 template <
class U,
class BASE>
3866 :
public SumBaseImpl<BASE, U>
3868 void update(U
const & t)
3871 this->value_ += pow(t, (
int)N);
3874 void update(U
const & t,
double weight)
3877 this->value_ += weight*pow(t, (
int)N);
3888 static std::string name()
3890 return "AbsPowerSum<1>";
3895 template <
class U,
class BASE>
3897 :
public SumBaseImpl<BASE, U>
3899 void update(U
const & t)
3902 this->value_ +=
abs(t);
3905 void update(U
const & t,
double weight)
3908 this->value_ += weight*
abs(t);
3917 template <
unsigned N>
3923 static std::string name()
3925 return std::string(
"AbsPowerSum<") + asString(N) +
">";
3930 template <
class U,
class BASE>
3932 :
public SumBaseImpl<BASE, U>
3934 void update(U
const & t)
3937 this->value_ += pow(
abs(t), (
int)N);
3940 void update(U
const & t,
double weight)
3943 this->value_ += weight*pow(
abs(t), (
int)N);
3948 template <
class BASE,
class VALUE_TYPE,
class U>
3949 struct CachedResultBase
3952 typedef typename AccumulatorResultTraits<U>::element_type element_type;
3953 typedef VALUE_TYPE value_type;
3954 typedef value_type
const & result_type;
3956 mutable value_type value_;
3964 value_ = element_type();
3968 template <
class Shape>
3969 void reshape(Shape
const & s)
3971 acc_detail::reshapeImpl(value_, s);
3979 void update(U
const &)
3984 void update(U
const &,
double)
3993 template <
class TAG>
3997 typedef typename StandardizeTag<TAG>::type TargetTag;
4000 static std::string name()
4002 return std::string(
"DivideByCount<") + TargetTag::name() +
" >";
4007 template <
class U,
class BASE>
4009 :
public CachedResultBase<BASE, typename LookupDependency<TargetTag, BASE>::value_type, U>
4011 typedef typename CachedResultBase<BASE, typename LookupDependency<TargetTag, BASE>::value_type, U>::result_type result_type;
4013 result_type operator()()
const 4017 using namespace multi_math;
4018 this->value_ = getDependency<TargetTag>(*this) / getDependency<Count>(*this);
4021 return this->value_;
4029 template <
class TAG>
4033 typedef typename StandardizeTag<TAG>::type TargetTag;
4036 static std::string name()
4038 return std::string(
"DivideUnbiased<") + TargetTag::name() +
" >";
4043 template <
class U,
class BASE>
4047 typedef typename LookupDependency<TargetTag, BASE>::value_type value_type;
4048 typedef value_type result_type;
4050 result_type operator()()
const 4052 using namespace multi_math;
4053 return getDependency<TargetTag>(*this) / (getDependency<Count>(*this) - 1.0);
4061 template <
class TAG>
4065 typedef typename StandardizeTag<DivideByCount<TAG> >::type TargetTag;
4068 static std::string name()
4070 typedef typename StandardizeTag<TAG>::type InnerTag;
4071 return std::string(
"RootDivideByCount<") + InnerTag::name() +
" >";
4076 template <
class U,
class BASE>
4080 typedef typename LookupDependency<TargetTag, BASE>::value_type value_type;
4081 typedef value_type result_type;
4083 result_type operator()()
const 4085 using namespace multi_math;
4086 return sqrt(getDependency<TargetTag>(*
this));
4094 template <
class TAG>
4098 typedef typename StandardizeTag<DivideUnbiased<TAG> >::type TargetTag;
4101 static std::string name()
4103 typedef typename StandardizeTag<TAG>::type InnerTag;
4104 return std::string(
"RootDivideUnbiased<") + InnerTag::name() +
" >";
4109 template <
class U,
class BASE>
4113 typedef typename LookupDependency<TargetTag, BASE>::value_type value_type;
4114 typedef value_type result_type;
4116 result_type operator()()
const 4118 using namespace multi_math;
4119 return sqrt(getDependency<TargetTag>(*
this));
4132 static std::string name()
4134 return "Central<PowerSum<2> >";
4139 template <
class U,
class BASE>
4141 :
public SumBaseImpl<BASE, U>
4146 double n1 = getDependency<Count>(*this), n2 = getDependency<Count>(o);
4149 this->value_ = o.value_;
4153 this->value_ += o.value_ + n1 * n2 / (n1 + n2) *
sq(getDependency<Mean>(*
this) - getDependency<Mean>(o));
4157 void update(U
const & t)
4159 double n = getDependency<Count>(*this);
4163 this->value_ += n / (n - 1.0) *
sq(getDependency<Mean>(*
this) - t);
4167 void update(U
const & t,
double weight)
4169 double n = getDependency<Count>(*this);
4173 this->value_ += n / (n - weight) *
sq(getDependency<Mean>(*
this) - t);
4187 static std::string name()
4189 return "Central<PowerSum<3> >";
4194 template <
class U,
class BASE>
4196 :
public SumBaseImpl<BASE, U>
4198 typedef typename SumBaseImpl<BASE, U>::value_type value_type;
4200 static const unsigned int workInPass = 2;
4207 double n1 = getDependency<Count>(*this), n2 = getDependency<Count>(o);
4210 this->value_ = o.value_;
4215 double weight = n1 * n2 * (n1 - n2) /
sq(n);
4216 value_type delta = getDependency<Mean>(o) - getDependency<Mean>(*
this);
4217 this->value_ += o.value_ + weight * pow(delta, 3) +
4218 3.0 / n * delta * (n1 * getDependency<Sum2Tag>(o) - n2 * getDependency<Sum2Tag>(*
this));
4222 void update(U
const & t)
4225 this->value_ += pow(getDependency<Centralize>(*
this), 3);
4228 void update(U
const & t,
double weight)
4231 this->value_ += weight*pow(getDependency<Centralize>(*
this), 3);
4243 static std::string name()
4245 return "Central<PowerSum<4> >";
4250 template <
class U,
class BASE>
4252 :
public SumBaseImpl<BASE, U>
4254 typedef typename SumBaseImpl<BASE, U>::value_type value_type;
4256 static const unsigned int workInPass = 2;
4264 double n1 = getDependency<Count>(*this), n2 = getDependency<Count>(o);
4267 this->value_ = o.value_;
4272 double n1_2 =
sq(n1);
4273 double n2_2 =
sq(n2);
4275 double weight = n1 * n2 * (n1_2 - n1*n2 + n2_2) / n_2 / n;
4276 value_type delta = getDependency<Mean>(o) - getDependency<Mean>(*
this);
4277 this->value_ += o.value_ + weight * pow(delta, 4) +
4278 6.0 / n_2 *
sq(delta) * (n1_2 * getDependency<Sum2Tag>(o) + n2_2 * getDependency<Sum2Tag>(*
this)) +
4279 4.0 / n * delta * (n1 * getDependency<Sum3Tag>(o) - n2 * getDependency<Sum3Tag>(*this));
4283 void update(U
const & t)
4286 this->value_ += pow(getDependency<Centralize>(*
this), 4);
4289 void update(U
const & t,
double weight)
4292 this->value_ += weight*pow(getDependency<Centralize>(*
this), 4);
4307 static std::string name()
4314 template <
class U,
class BASE>
4318 static const unsigned int workInPass = 2;
4320 typedef typename LookupDependency<Central<PowerSum<3> >, BASE>::value_type value_type;
4321 typedef value_type result_type;
4323 result_type operator()()
const 4328 using namespace multi_math;
4329 return sqrt(getDependency<Count>(*
this)) * getDependency<Sum3>(*this) / pow(getDependency<Sum2>(*
this), 1.5);
4343 static std::string name()
4345 return "UnbiasedSkewness";
4350 template <
class U,
class BASE>
4354 static const unsigned int workInPass = 2;
4356 typedef typename LookupDependency<Central<PowerSum<3> >, BASE>::value_type value_type;
4357 typedef value_type result_type;
4359 result_type operator()()
const 4361 using namespace multi_math;
4362 double n = getDependency<Count>(*this);
4363 return sqrt(n*(n-1.0)) / (n - 2.0) * getDependency<Skewness>(*this);
4379 static std::string name()
4386 template <
class U,
class BASE>
4390 static const unsigned int workInPass = 2;
4392 typedef typename LookupDependency<Central<PowerSum<4> >, BASE>::value_type value_type;
4393 typedef value_type result_type;
4395 result_type operator()()
const 4400 using namespace multi_math;
4401 return getDependency<Count>(*this) * getDependency<Sum4>(*this) /
sq(getDependency<Sum2>(*
this)) - value_type(3.0);
4415 static std::string name()
4417 return "UnbiasedKurtosis";
4422 template <
class U,
class BASE>
4426 static const unsigned int workInPass = 2;
4428 typedef typename LookupDependency<Central<PowerSum<4> >, BASE>::value_type value_type;
4429 typedef value_type result_type;
4431 result_type operator()()
const 4433 using namespace multi_math;
4434 double n = getDependency<Count>(*this);
4435 return (n-1.0)/((n-2.0)*(n-3.0))*((n+1.0)*getDependency<Kurtosis>(*this) + value_type(6.0));
4440 namespace acc_detail {
4442 template <
class Scatter,
class Sum>
4443 void updateFlatScatterMatrix(Scatter & sc,
Sum const & s,
double w)
4445 int size = s.size();
4448 sc[k] += w*s[i]*s[j];
4451 template <
class Sum>
4452 void updateFlatScatterMatrix(
double & sc,
Sum const & s,
double w)
4457 template <
class Cov,
class Scatter>
4458 void flatScatterMatrixToScatterMatrix(Cov & cov, Scatter
const & sc)
4460 int size = cov.shape(0), k=0;
4467 cov(j,i) = cov(i,j);
4472 template <
class Scatter>
4473 void flatScatterMatrixToScatterMatrix(
double & cov, Scatter
const & sc)
4478 template <
class Cov,
class Scatter>
4479 void flatScatterMatrixToCovariance(Cov & cov, Scatter
const & sc,
double n)
4481 int size = cov.shape(0), k=0;
4484 cov(j,j) = sc[k++] / n;
4487 cov(i,j) = sc[k++] / n;
4488 cov(j,i) = cov(i,j);
4493 template <
class Scatter>
4494 void flatScatterMatrixToCovariance(
double & cov, Scatter
const & sc,
double n)
4511 static std::string name()
4513 return "FlatScatterMatrix";
4518 template <
class U,
class BASE>
4522 typedef typename AccumulatorResultTraits<U>::element_promote_type element_type;
4523 typedef typename AccumulatorResultTraits<U>::FlatCovarianceType value_type;
4524 typedef value_type
const & result_type;
4526 typedef typename AccumulatorResultTraits<U>::SumType SumType;
4538 value_ = element_type();
4541 template <
class Shape>
4542 void reshape(Shape
const & s)
4545 acc_detail::reshapeImpl(value_,
Shape1(size*(size+1)/2));
4546 acc_detail::reshapeImpl(diff_, s);
4551 double n1 = getDependency<Count>(*this), n2 = getDependency<Count>(o);
4559 diff_ = getDependency<Mean>(*this) - getDependency<Mean>(o);
4560 acc_detail::updateFlatScatterMatrix(value_, diff_, n1 * n2 / (n1 + n2));
4565 void update(U
const & t)
4570 void update(U
const & t,
double weight)
4575 result_type operator()()
const 4581 void compute(U
const & t,
double weight = 1.0)
4583 double n = getDependency<Count>(*this);
4587 diff_ = getDependency<Mean>(*this) - t;
4588 acc_detail::updateFlatScatterMatrix(value_, diff_, n * weight / (n - weight));
4601 static std::string name()
4603 return "DivideByCount<FlatScatterMatrix>";
4608 template <
class U,
class BASE>
4610 :
public CachedResultBase<BASE, typename AccumulatorResultTraits<U>::CovarianceType, U>
4612 typedef CachedResultBase<BASE, typename AccumulatorResultTraits<U>::CovarianceType, U> BaseType;
4613 typedef typename BaseType::result_type result_type;
4615 template <
class Shape>
4616 void reshape(Shape
const & s)
4619 acc_detail::reshapeImpl(this->value_,
Shape2(size,size));
4622 result_type operator()()
const 4626 acc_detail::flatScatterMatrixToCovariance(this->value_, getDependency<FlatScatterMatrix>(*
this), getDependency<Count>(*
this));
4629 return this->value_;
4641 static std::string name()
4643 return "DivideUnbiased<FlatScatterMatrix>";
4648 template <
class U,
class BASE>
4650 :
public CachedResultBase<BASE, typename AccumulatorResultTraits<U>::CovarianceType, U>
4652 typedef CachedResultBase<BASE, typename AccumulatorResultTraits<U>::CovarianceType, U> BaseType;
4653 typedef typename BaseType::result_type result_type;
4655 template <
class Shape>
4656 void reshape(Shape
const & s)
4659 acc_detail::reshapeImpl(this->value_,
Shape2(size,size));
4662 result_type operator()()
const 4666 acc_detail::flatScatterMatrixToCovariance(this->value_, getDependency<FlatScatterMatrix>(*
this), getDependency<Count>(*
this) - 1.0);
4669 return this->value_;
4681 static std::string name()
4683 return "ScatterMatrixEigensystem";
4688 template <
class U,
class BASE>
4692 typedef typename AccumulatorResultTraits<U>::element_promote_type element_type;
4693 typedef typename AccumulatorResultTraits<U>::SumType EigenvalueType;
4694 typedef typename AccumulatorResultTraits<U>::CovarianceType EigenvectorType;
4695 typedef std::pair<EigenvalueType, EigenvectorType> value_type;
4696 typedef value_type
const & result_type;
4698 mutable value_type value_;
4706 if(!acc_detail::hasDataImpl(value_.second))
4708 acc_detail::copyShapeImpl(o.value_.first, value_.first);
4709 acc_detail::copyShapeImpl(o.value_.second, value_.second);
4714 void update(U
const &)
4719 void update(U
const &,
double)
4726 value_.first = element_type();
4727 value_.second = element_type();
4731 template <
class Shape>
4732 void reshape(Shape
const & s)
4735 acc_detail::reshapeImpl(value_.first,
Shape1(size));
4736 acc_detail::reshapeImpl(value_.second,
Shape2(size,size));
4739 result_type operator()()
const 4743 compute(getDependency<FlatScatterMatrix>(*
this), value_.first, value_.second);
4750 template <
class Flat,
class EW,
class EV>
4751 static void compute(Flat
const & flatScatter, EW & ew, EV & ev)
4753 EigenvectorType scatter(ev.shape());
4754 acc_detail::flatScatterMatrixToScatterMatrix(scatter, flatScatter);
4760 static void compute(
double v,
double & ew,
double & ev)
4775 static std::string name()
4777 return "DivideByCount<ScatterMatrixEigensystem>";
4782 template <
class U,
class BASE>
4786 typedef typename LookupDependency<ScatterMatrixEigensystem, BASE>::type SMImpl;
4787 typedef typename SMImpl::element_type element_type;
4788 typedef typename SMImpl::EigenvalueType EigenvalueType;
4789 typedef typename SMImpl::EigenvectorType EigenvectorType;
4790 typedef std::pair<EigenvalueType, EigenvectorType const &> value_type;
4791 typedef value_type
const & result_type;
4793 mutable value_type value_;
4796 : value_(EigenvalueType(), BASE::template call_getDependency<ScatterMatrixEigensystem>().second)
4804 void update(U
const &)
4809 void update(U
const &,
double)
4816 value_.first = element_type();
4820 template <
class Shape>
4821 void reshape(Shape
const & s)
4824 acc_detail::reshapeImpl(value_.first,
Shape2(size,1));
4827 result_type operator()()
const 4831 value_.first = getDependency<ScatterMatrixEigensystem>(*this).first / getDependency<Count>(*this);
4929 static std::string name()
4931 return "Principal<PowerSum<2> >";
4936 template <
class U,
class BASE>
4940 typedef typename LookupDependency<ScatterMatrixEigensystem, BASE>::type::EigenvalueType value_type;
4941 typedef value_type
const & result_type;
4943 result_type operator()()
const 4945 return getDependency<ScatterMatrixEigensystem>(*this).first;
4960 static std::string name()
4962 return "Principal<CoordinateSystem>";
4967 template <
class U,
class BASE>
4971 typedef typename LookupDependency<ScatterMatrixEigensystem, BASE>::type::EigenvectorType value_type;
4972 typedef value_type
const & result_type;
4974 result_type operator()()
const 4976 return getDependency<ScatterMatrixEigensystem>(*this).second;
4990 static std::string name()
4997 template <
class U,
class BASE>
5001 typedef typename AccumulatorResultTraits<U>::element_type element_type;
5002 typedef typename AccumulatorResultTraits<U>::MinmaxType value_type;
5003 typedef value_type
const & result_type;
5009 value_ = NumericTraits<element_type>::max();
5014 value_ = NumericTraits<element_type>::max();
5017 template <
class Shape>
5018 void reshape(Shape
const & s)
5020 acc_detail::reshapeImpl(value_, s, NumericTraits<element_type>::max());
5025 updateImpl(o.value_);
5028 void update(U
const & t)
5033 void update(U
const & t,
double)
5038 result_type operator()()
const 5045 void updateImpl(T
const & o)
5047 using namespace multi_math;
5048 value_ = min(value_, o);
5051 template <
class T,
class Alloc>
5054 value_ = multi_math::min(value_, o);
5068 static std::string name()
5075 template <
class U,
class BASE>
5079 typedef typename AccumulatorResultTraits<U>::element_type element_type;
5080 typedef typename AccumulatorResultTraits<U>::MinmaxType value_type;
5081 typedef value_type
const & result_type;
5087 value_ = NumericTraits<element_type>::min();
5092 value_ = NumericTraits<element_type>::min();
5095 template <
class Shape>
5096 void reshape(Shape
const & s)
5098 acc_detail::reshapeImpl(value_, s, NumericTraits<element_type>::min());
5103 updateImpl(o.value_);
5106 void update(U
const & t)
5111 void update(U
const & t,
double)
5116 result_type operator()()
const 5123 void updateImpl(T
const & o)
5125 using namespace multi_math;
5126 value_ = max(value_, o);
5129 template <
class T,
class Alloc>
5132 value_ = multi_math::max(value_, o);
5146 static std::string name()
5148 return "ArgMinWeight";
5153 template <
class U,
class BASE>
5157 typedef typename AccumulatorResultTraits<U>::element_type element_type;
5158 typedef typename AccumulatorResultTraits<U>::MinmaxType value_type;
5159 typedef value_type
const & result_type;
5165 : min_weight_(NumericTraits<double>::max()),
5171 min_weight_ = NumericTraits<double>::max();
5172 value_ = element_type();
5175 template <
class Shape>
5176 void reshape(Shape
const & s)
5178 acc_detail::reshapeImpl(value_, s);
5183 using namespace multi_math;
5184 if(o.min_weight_ < min_weight_)
5186 min_weight_ = o.min_weight_;
5191 void update(U
const & t)
5193 vigra_precondition(
false,
"ArgMinWeight::update() needs weights.");
5196 void update(U
const & t,
double weight)
5198 if(weight < min_weight_)
5200 min_weight_ = weight;
5205 result_type operator()()
const 5221 static std::string name()
5223 return "ArgMaxWeight";
5228 template <
class U,
class BASE>
5232 typedef typename AccumulatorResultTraits<U>::element_type element_type;
5233 typedef typename AccumulatorResultTraits<U>::MinmaxType value_type;
5234 typedef value_type
const & result_type;
5240 : max_weight_(NumericTraits<double>::min()),
5246 max_weight_ = NumericTraits<double>::min();
5247 value_ = element_type();
5250 template <
class Shape>
5251 void reshape(Shape
const & s)
5253 acc_detail::reshapeImpl(value_, s);
5258 using namespace multi_math;
5259 if(o.max_weight_ > max_weight_)
5261 max_weight_ = o.max_weight_;
5266 void update(U
const & t)
5268 vigra_precondition(
false,
"ArgMaxWeight::update() needs weights.");
5271 void update(U
const & t,
double weight)
5273 if(weight > max_weight_)
5275 max_weight_ = weight;
5280 result_type operator()()
const 5288 template <
class BASE,
int BinCount>
5294 typedef double element_type;
5296 typedef value_type
const & result_type;
5299 double left_outliers, right_outliers;
5309 value_ = element_type();
5310 left_outliers = 0.0;
5311 right_outliers = 0.0;
5317 left_outliers += o.left_outliers;
5318 right_outliers += o.right_outliers;
5321 result_type operator()()
const 5327 template <
class BASE>
5328 class HistogramBase<BASE, 0>
5333 typedef double element_type;
5335 typedef value_type
const & result_type;
5338 double left_outliers, right_outliers;
5348 value_ = element_type();
5349 left_outliers = 0.0;
5350 right_outliers = 0.0;
5355 if(value_.size() == 0)
5359 else if(o.value_.size() > 0)
5361 vigra_precondition(value_.size() == o.value_.size(),
5362 "HistogramBase::operator+=(): bin counts must be equal.");
5365 left_outliers += o.left_outliers;
5366 right_outliers += o.right_outliers;
5369 void setBinCount(
int binCount)
5371 vigra_precondition(binCount > 0,
5372 "HistogramBase:.setBinCount(): binCount > 0 required.");
5373 value_type(
Shape1(binCount)).swap(value_);
5376 result_type operator()()
const 5382 template <
class BASE,
int BinCount,
class U=
typename BASE::input_type>
5383 class RangeHistogramBase
5384 :
public HistogramBase<BASE, BinCount>
5387 double scale_, offset_, inverse_scale_;
5389 RangeHistogramBase()
5399 inverse_scale_ = 0.0;
5400 HistogramBase<BASE, BinCount>::reset();
5403 void operator+=(RangeHistogramBase
const & o)
5405 vigra_precondition(scale_ == 0.0 || o.scale_ == 0.0 || (scale_ == o.scale_ && offset_ == o.offset_),
5406 "RangeHistogramBase::operator+=(): cannot merge histograms with different data mapping.");
5412 offset_ = o.offset_;
5413 inverse_scale_ = o.inverse_scale_;
5417 void update(U
const & t)
5422 void update(U
const & t,
double weight)
5424 double m = mapItem(t);
5425 int index = (m == (double)this->value_.size())
5429 this->left_outliers += weight;
5430 else if(index >= (
int)this->value_.size())
5431 this->right_outliers += weight;
5433 this->value_[index] += weight;
5436 void setMinMax(
double mi,
double ma)
5438 vigra_precondition(this->value_.size() > 0,
5439 "RangeHistogramBase::setMinMax(...): setBinCount(...) has not been called.");
5440 vigra_precondition(mi < ma,
5441 "RangeHistogramBase::setMinMax(...): min < max required.");
5443 scale_ = (double)this->value_.size() / (ma - mi);
5444 inverse_scale_ = 1.0 / scale_;
5447 double mapItem(
double t)
const 5449 return scale_ * (t - offset_);
5452 double mapItemInverse(
double t)
const 5454 return inverse_scale_ * t + offset_;
5457 template <
class ArrayLike>
5458 void computeStandardQuantiles(
double minimum,
double maximum,
double count,
5459 ArrayLike
const & desiredQuantiles, ArrayLike & res)
const 5466 double mappedMinimum = mapItem(minimum);
5467 double mappedMaximum = mapItem(maximum);
5469 keypoints.push_back(mappedMinimum);
5470 cumhist.push_back(0.0);
5472 if(this->left_outliers > 0.0)
5474 keypoints.push_back(0.0);
5475 cumhist.push_back(this->left_outliers);
5478 int size = (int)this->value_.size();
5479 double cumulative = this->left_outliers;
5480 for(
int k=0; k<size; ++k)
5482 if(this->value_[k] > 0.0)
5484 if(keypoints.
back() <= k)
5486 keypoints.push_back(k);
5487 cumhist.push_back(cumulative);
5489 cumulative += this->value_[k];
5490 keypoints.push_back(k+1);
5491 cumhist.push_back(cumulative);
5495 if(this->right_outliers > 0.0)
5497 if(keypoints.
back() != size)
5499 keypoints.push_back(size);
5500 cumhist.push_back(cumulative);
5502 keypoints.push_back(mappedMaximum);
5503 cumhist.push_back(count);
5507 keypoints.
back() = mappedMaximum;
5508 cumhist.
back() = count;
5511 int quantile = 0, end = (int)desiredQuantiles.size();
5513 if(desiredQuantiles[0] == 0.0)
5518 if(desiredQuantiles[end-1] == 1.0)
5520 res[end-1] = maximum;
5525 double qcount = count * desiredQuantiles[quantile];
5526 while(quantile < end)
5528 if(cumhist[point] < qcount && cumhist[point+1] >= qcount)
5530 double t = (qcount - cumhist[point]) / (cumhist[point+1] - cumhist[point]) * (keypoints[point+1] - keypoints[point]);
5531 res[quantile] = mapItemInverse(t + keypoints[point]);
5533 qcount = count * desiredQuantiles[quantile];
5551 template <
int BinCount>
5558 static std::string name()
5560 return std::string(
"IntegerHistogram<") + asString(BinCount) +
">";
5565 template <
class U,
class BASE>
5567 :
public HistogramBase<BASE, BinCount>
5569 void update(
int index)
5572 ++this->left_outliers;
5573 else if(index >= (
int)this->value_.size())
5574 ++this->right_outliers;
5576 ++this->value_[index];
5579 void update(
int index,
double weight)
5583 vigra_precondition(
false,
"IntegerHistogram::update(): weighted histograms not supported, use another histogram type.");
5586 template <
class ArrayLike>
5587 void computeStandardQuantiles(
double minimum,
double maximum,
double count,
5588 ArrayLike
const & desiredQuantiles, ArrayLike & res)
const 5590 int quantile = 0, end = (int)desiredQuantiles.size();
5592 if(desiredQuantiles[0] == 0.0)
5597 if(desiredQuantiles[end-1] == 1.0)
5599 res[end-1] = maximum;
5604 int currentBin = 0, size = (int)this->value_.size();
5605 double cumulative1 = this->left_outliers,
5606 cumulative2 = this->value_[currentBin] + cumulative1;
5610 double qcount = desiredQuantiles[quantile]*count + 1.0;
5612 while(quantile < end)
5614 if(cumulative2 == qcount)
5616 res[quantile] = currentBin;
5618 qcount = desiredQuantiles[quantile]*count + 1.0;
5620 else if(cumulative2 > qcount)
5622 if(cumulative1 > qcount)
5624 res[quantile] = minimum;
5626 if(cumulative1 + 1.0 > qcount)
5628 res[quantile] = currentBin - 1 + qcount -
std::floor(qcount);
5632 res[quantile] = currentBin;
5635 qcount = desiredQuantiles[quantile]*count + 1.0;
5637 else if(currentBin == size-1)
5639 res[quantile] = maximum;
5641 qcount = desiredQuantiles[quantile]*count + 1.0;
5646 cumulative1 = cumulative2;
5647 cumulative2 += this->value_[currentBin];
5664 template <
int BinCount>
5671 static std::string name()
5673 return std::string(
"UserRangeHistogram<") + asString(BinCount) +
">";
5678 template <
class U,
class BASE>
5680 :
public RangeHistogramBase<BASE, BinCount, U>
5682 void update(U
const & t)
5687 void update(U
const & t,
double weight)
5689 vigra_precondition(this->scale_ != 0.0,
5690 "UserRangeHistogram::update(): setMinMax(...) has not been called.");
5692 RangeHistogramBase<BASE, BinCount, U>::update(t, weight);
5706 template <
int BinCount>
5713 static std::string name()
5715 return std::string(
"AutoRangeHistogram<") + asString(BinCount) +
">";
5720 template <
class U,
class BASE>
5722 :
public RangeHistogramBase<BASE, BinCount, U>
5724 static const unsigned int workInPass = LookupDependency<Minimum, BASE>::type::workInPass + 1;
5726 void update(U
const & t)
5731 void update(U
const & t,
double weight)
5733 if(this->scale_ == 0.0)
5734 this->setMinMax(getDependency<Minimum>(*
this), getDependency<Maximum>(*
this));
5736 RangeHistogramBase<BASE, BinCount, U>::update(t, weight);
5750 template <
int BinCount>
5757 static std::string name()
5759 return std::string(
"GlobalRangeHistogram<") + asString(BinCount) +
">";
5764 template <
class U,
class BASE>
5766 :
public RangeHistogramBase<BASE, BinCount, U>
5768 static const unsigned int workInPass = LookupDependency<Minimum, BASE>::type::workInPass + 1;
5770 bool useLocalMinimax_;
5773 : useLocalMinimax_(
false)
5776 void setRegionAutoInit(
bool locally)
5779 useLocalMinimax_ = locally;
5782 void update(U
const & t)
5787 void update(U
const & t,
double weight)
5789 if(this->scale_ == 0.0)
5791 if(useLocalMinimax_)
5792 this->setMinMax(getDependency<Minimum>(*
this), getDependency<Maximum>(*
this));
5794 this->setMinMax(getDependency<
Global<Minimum> >(*
this), getDependency<Global<Maximum> >(*
this));
5797 RangeHistogramBase<BASE, BinCount, U>::update(t, weight);
5806 template <
class HistogramAccumulator>
5811 typedef typename StandardizeTag<HistogramAccumulator>::type HistogramTag;
5814 static std::string name()
5816 return std::string(
"StandardQuantiles<") + HistogramTag::name() +
" >";
5821 template <
class U,
class BASE>
5823 :
public CachedResultBase<BASE, TinyVector<double, 7>, U>
5825 typedef typename CachedResultBase<BASE, TinyVector<double, 7>, U>::result_type result_type;
5826 typedef typename CachedResultBase<BASE, TinyVector<double, 7>, U>::value_type value_type;
5828 static const unsigned int workInPass = LookupDependency<HistogramTag, BASE>::type::workInPass;
5830 result_type operator()()
const 5834 double desiredQuantiles[] = {0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 1.0 };
5835 getAccumulator<HistogramTag>(*this).computeStandardQuantiles(getDependency<Minimum>(*
this), getDependency<Maximum>(*
this),
5836 getDependency<Count>(*
this), value_type(desiredQuantiles),
5840 return this->value_;
5847 #endif // VIGRA_ACCUMULATOR_HXX void operator+=(AccumulatorChainArray const &o)
Definition: accumulator.hxx:2302
Basic statistic. Data value where weight assumes its minimal value.
Definition: accumulator.hxx:5141
Histogram where user provides bounds for linear range mapping from values to indices.
Definition: accumulator-grammar.hxx:71
Basic statistic. PowerSum<N> = .
Definition: accumulator-grammar.hxx:59
reference back()
Definition: array_vector.hxx:293
ArrayVector< std::string > activeNames() const
Definition: accumulator.hxx:2203
Basic statistic. Maximum value.
Definition: accumulator.hxx:5063
unsigned int passesRequired() const
Definition: accumulator.hxx:2466
Modifier. Compute statistic globally rather than per region.
Definition: accumulator-grammar.hxx:145
Definition: fftw3.hxx:623
Basic statistic. Skewness.
Definition: accumulator.hxx:4302
const difference_type & shape() const
Definition: multi_array.hxx:1551
unsigned int passesRequired() const
Definition: accumulator.hxx:2214
void reshape(TinyVector< U, N > const &s)
Definition: accumulator.hxx:2052
Basic statistic. Identity matrix of appropriate size.
Definition: accumulator.hxx:3705
ArrayVector< std::string > activeNames() const
Definition: accumulator.hxx:2456
const_iterator begin() const
Definition: array_vector.hxx:223
void setMaxRegionLabel(unsigned label)
Definition: accumulator.hxx:2281
Basic statistic. Kurtosis.
Definition: accumulator.hxx:4374
Basic statistic. Unbiased Kurtosis.
Definition: accumulator.hxx:4410
Main MultiArray class containing the memory management.
Definition: multi_array.hxx:2357
bool validMinMax() const
Definition: histogram.hxx:118
void activateAll()
Definition: accumulator.hxx:2179
int binCount
Total number of bins in the histogram.
Definition: histogram.hxx:60
Histogram where range mapping bounds are defined by minimum and maximum of data.
Definition: accumulator-grammar.hxx:72
LookupTag< TAG, A >::reference getAccumulator(A &a)
Definition: accumulator.hxx:2771
Create an accumulator chain containing the selected statistics and their dependencies.
Definition: accumulator.hxx:2040
Basic statistic. Flattened uppter-triangular part of scatter matrix.
Definition: accumulator.hxx:4506
Modifier. Substract mean before computing statistic.
Definition: accumulator-grammar.hxx:139
Compute weighted version of the statistic.
Definition: accumulator-grammar.hxx:134
Wrapper for MakeTypeList that additionally performs tag standardization.
Definition: accumulator.hxx:389
std::ptrdiff_t MultiArrayIndex
Definition: multi_shape.hxx:55
bool isActive(A const &a)
Definition: accumulator.hxx:2866
Create an array of dynamic accumulator chains containing the selected per-region and global statistic...
Definition: accumulator.hxx:2411
Definition: accessor.hxx:43
bool isActive(std::string tag) const
Definition: accumulator.hxx:2439
void activate(std::string tag)
Definition: accumulator.hxx:2163
Specialization (covariance eigenvectors): works in pass 1, operator+=() supported (merging)...
Definition: accumulator.hxx:4955
bool isActive() const
Definition: accumulator.hxx:2450
bool isActive() const
Definition: accumulator.hxx:2196
FFTWComplex< R > & operator+=(FFTWComplex< R > &a, const FFTWComplex< R > &b)
add-assignment
Definition: fftw3.hxx:859
NumericTraits< T >::Promote sq(T t)
The square function.
Definition: mathutil.hxx:344
void activate()
Definition: accumulator.hxx:2426
Basic statistic. Unbiased Skewness.
Definition: accumulator.hxx:4338
NumericTraits< V >::Promote prod(TinyVectorBase< V, SIZE, D1, D2 > const &l)
product of the vector's elements
Definition: tinyvector.hxx:1895
void activate()
Definition: accumulator.hxx:2172
bool symmetricEigensystem(MultiArrayView< 2, T, C1 > const &a, MultiArrayView< 2, T, C2 > &ew, MultiArrayView< 2, T, C3 > &ev)
Definition: eigensystem.hxx:1008
void merge(AccumulatorChainArray const &o)
Definition: accumulator.hxx:2318
vigra::MultiArrayView< N, T, Stride >::const_reference get(vigra::MultiArrayView< N, T, Stride > const &pmap, typename vigra::MultiArrayView< N, T, Stride >::difference_type const &k)
Read the value at key k in property map pmap (API: boost).
Definition: multi_gridgraph.hxx:2859
void extractFeatures(...)
Specifies index of labels in CoupledHandle.
Definition: accumulator-grammar.hxx:95
void activateAll()
Definition: accumulator.hxx:2432
static ArrayVector< std::string > const & tagNames()
Definition: accumulator.hxx:2339
Iterator argMax(Iterator first, Iterator last)
Find the maximum element in a sequence.
Definition: algorithm.hxx:96
Specifies index of data in CoupledHandle.
Definition: accumulator-grammar.hxx:94
unsigned int regionCount() const
Definition: accumulator.hxx:2295
PowerSum< 1 > Sum
Alias. Sum.
Definition: accumulator-grammar.hxx:156
Class for fixed size vectors.This class contains an array of size SIZE of the specified VALUETYPE...
Definition: accessor.hxx:940
Definition: multi_iterator_coupled.hxx:52
void ignoreLabel(MultiArrayIndex l)
Definition: accumulator.hxx:2274
Definition: accumulator.hxx:4676
Modifier. Project onto PCA eigenvectors.
Definition: accumulator-grammar.hxx:140
MultiArrayShape< 2 >::type Shape2
shape type for MultiArray<2, T>
Definition: multi_shape.hxx:241
Histogram where data values are equal to bin indices.
Definition: accumulator-grammar.hxx:70
bool hasData() const
Definition: multi_array.hxx:1807
Basic statistic. Data where weight assumes its maximal value.
Definition: accumulator.hxx:5216
bool isActive(std::string tag) const
Definition: accumulator.hxx:2185
MultiArrayShape< 1 >::type Shape1
shape type for MultiArray<1, T>
Definition: multi_shape.hxx:240
static ArrayVector< std::string > const & tagNames()
Definition: accumulator.hxx:2062
CoupledIteratorType< N >::type createCoupledIterator(TinyVector< MultiArrayIndex, N > const &shape)
Definition: multi_iterator_coupled.hxx:1052
FFTWComplex< R >::NormType abs(const FFTWComplex< R > &a)
absolute value (= magnitude)
Definition: fftw3.hxx:1002
bool local_auto_init
If true, range mapping bounds are defined by minimum and maximum of the data.
Definition: histogram.hxx:63
Base class for, and view to, vigra::MultiArray.
Definition: multi_array.hxx:655
void merge(unsigned i, unsigned j)
Definition: accumulator.hxx:2309
Modifier. RootDivideByCount<TAG> = sqrt( TAG/Count )
Definition: accumulator-grammar.hxx:128
void activate(std::string tag)
Definition: accumulator.hxx:2418
MultiArrayIndex maxRegionLabel() const
Definition: accumulator.hxx:2288
Compute (0%, 10%, 25%, 50%, 75%, 90%, 100%) quantiles from given histogram.
Definition: accumulator-grammar.hxx:77
const_iterator end() const
Definition: array_vector.hxx:237
double maximum
Upper bound for linear range mapping from values to indices.
Definition: histogram.hxx:57
void merge(AccumulatorChainArray const &o, ArrayLike const &labelMapping)
Definition: accumulator.hxx:2330
Iterate over multiple images simultaneously in scan order.
Definition: multi_iterator_coupled.hxx:526
Class for a single RGB value.
Definition: accessor.hxx:938
Modifier. Divide statistic by Count: DivideByCount<TAG> = TAG / Count .
Definition: accumulator-grammar.hxx:127
Basic statistic. AbsPowerSum<N> = .
Definition: accumulator-grammar.hxx:60
void activate(A &a)
Definition: accumulator.hxx:2855
Specifies index of data in CoupledHandle.
Definition: accumulator-grammar.hxx:93
Like AutoRangeHistogram, but use global min/max rather than region min/max.
Definition: accumulator-grammar.hxx:73
int floor(FixedPoint< IntBits, FracBits > v)
rounding down.
Definition: fixedpoint.hxx:667
Basic statistic. Minimum value.
Definition: accumulator.hxx:4985
Create a dynamic accumulator chain containing the selected statistics and their dependencies.
Definition: accumulator.hxx:2154
Modifier. Divide statistics by Count-1: DivideUnbiased<TAG> = TAG / (Count-1)
Definition: accumulator-grammar.hxx:129
Modifier. Compute statistic from pixel coordinates rather than from pixel values. ...
Definition: accumulator-grammar.hxx:133
SquareRootTraits< FixedPoint< IntBits, FracBits > >::SquareRootResult sqrt(FixedPoint< IntBits, FracBits > v)
square root.
Definition: fixedpoint.hxx:616
double minimum
Lower bound for linear range mapping from values to indices.
Definition: histogram.hxx:54
Create an array of accumulator chains containing the selected per-region and global statistics and th...
Definition: accumulator.hxx:2261
Modifier. RootDivideUnbiased<TAG> = sqrt( TAG / (Count-1) )
Definition: accumulator-grammar.hxx:130
Set histogram options.
Definition: histogram.hxx:49