Scope
ScopeMultiHistogram.cpp
1 #include "StdAfx.h"
2 #include "ScopeMultiHistogram.h"
3 #include "ScopeHistogram.h"
4 #include "ScopeMultiImage.h"
5 
6 namespace scope {
7 
8 ScopeMultiHistogram::ScopeMultiHistogram(const uint32_t& _area, const uint32_t& _channels, const uint32_t& _no_of_bins, uint16_t _range)
9  : area(_area)
10  , channels(_channels)
11  , hists(channels) {
12  std::generate(std::begin(hists), std::end(hists), [&]() {
13  return std::make_shared<ScopeHistogram>(_no_of_bins, _range); } );
14 }
15 
16 void ScopeMultiHistogram::Calculate(ScopeMultiImageCPtr const _multi, const bool& _loghistogram) {
17  assert(hists.size() == _multi->Channels());
18  for ( size_t c = 0 ; c < hists.size() ; c++ )
19  hists.at(c)->Calculate(_multi->GetChannel(c), _loghistogram);
20 }
21 
22 void ScopeMultiHistogram::Resize(const uint32_t& _no_of_bins) {
23  std::for_each(std::begin(hists), std::end(hists), [&](ScopeHistogramPtr h) {
24  h->Resize(_no_of_bins); } );
25 }
26 
27 std::vector<uint32_t> ScopeMultiHistogram::MaxCounts() const {
28  std::vector<uint32_t> counts(hists.size(), 0);
29  std::transform(std::begin(counts), std::end(counts), std::begin(hists), std::begin(counts), [](const uint32_t& c, ScopeHistogramPtr h) {
30  return h->MaxCount(); } );
31  return counts;
32 }
33 
34 std::vector<uint16_t> ScopeMultiHistogram::FirstCountPositions() const {
35  std::vector<uint16_t> positions(hists.size(), 0);
36  std::transform(std::begin(positions), std::end(positions), std::begin(hists), std::begin(positions), [](const uint32_t& c, ScopeHistogramPtr h) {
37  return h->FirstCountPosition(); } );
38  return positions;
39 }
40 
41 std::vector<uint16_t> ScopeMultiHistogram::LastCountPositions() const {
42  std::vector<uint16_t> positions(hists.size(), 0);
43  std::transform(std::begin(positions), std::end(positions), std::begin(hists), std::begin(positions), [](const uint32_t& c, ScopeHistogramPtr h) {
44  return h->LastCountPosition(); } );
45  return positions;
46 }
47 
48 const std::vector<uint32_t>* ScopeMultiHistogram::GetHistConst(const uint32_t& _c) const {
49  return hists.at(_c)->GetHistConst();
50 }
51 
52 void ScopeMultiHistogram::ReleaseHistConst(const uint32_t& _c) const {
53  hists.at(_c)->ReleaseHistConst();
54 }
55 
56 }
void Calculate(ScopeMultiImageCPtr const _multi, const bool &_loghistogram=false)
const std::vector< uint32_t > * GetHistConst(const uint32_t &_c) const
This is the include file for standard system include files, or project specific include files that ar...
std::vector< uint16_t > LastCountPositions() const
std::vector< uint16_t > FirstCountPositions() const
std::vector< ScopeHistogramPtr > hists
vector with histograms for each channel
std::vector< uint32_t > MaxCounts() const
ScopeMultiHistogram(const uint32_t &_area=0, const uint32_t &_channels=1, const uint32_t &_no_of_bins=512, uint16_t _range=UINT16_MAX)
Initialize all channels.
void Resize(const uint32_t &_no_of_bins)
Resize the multi histogram to a new number of bins.
void ReleaseHistConst(const uint32_t &_c) const