MCPcopy Create free account
hub / github.com/MITK/MITK / ComputeFromBaseData

Method ComputeFromBaseData

Modules/AlgorithmsExt/src/mitkSimpleHistogram.cpp:20–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace mitk
19{
20 void SimpleImageHistogram::ComputeFromBaseData(BaseData *src)
21 {
22 valid = false;
23
24 // check if input is valid
25 if (src == nullptr)
26 return;
27 auto *source = dynamic_cast<Image *>(src);
28 if (source == nullptr)
29 return;
30 else if (source->IsEmpty())
31 return;
32
33 auto generator = mitk::HistogramGenerator::New();
34 generator->SetImage(source);
35 generator->SetSize(nBins);
36 generator->ComputeHistogram();
37 histogram = static_cast<mitk::SimpleImageHistogram::HistogramType::ConstPointer> (generator->GetHistogram());
38
39 CountType highest = 0;
40 for (unsigned int i = 0; i < histogram->GetSize()[0]; ++i)
41 {
42 CountType count = histogram->GetFrequency(i);
43 if (count > highest)
44 highest = count;
45 }
46 invLogHighest = 1.0 / log(double(highest));
47 valid = true;
48 }
49
50 bool SimpleImageHistogram::GetValid() { return valid; }
51 float SimpleImageHistogram::GetRelativeBin(double left, double right) const

Callers 3

mitkSimpleHistogramTestFunction · 0.45
ComputeFromBaseDataMethod · 0.45
operator[]Method · 0.45

Calls 7

ComputeHistogramMethod · 0.80
NewFunction · 0.50
IsEmptyMethod · 0.45
SetImageMethod · 0.45
SetSizeMethod · 0.45
GetHistogramMethod · 0.45
GetSizeMethod · 0.45

Tested by 1

mitkSimpleHistogramTestFunction · 0.36