#include <QmitkTransferFunctionCanvas.h>
Public Types | |
| typedef itk::Image< short, 3 > | CTImage |
| typedef itk::ImageRegionIterator < CTImage > | CTIteratorType |
| typedef itk::ImageRegionIteratorWithIndex < CTImage > | CTIteratorIndexType |
| typedef itk::Image< unsigned char, 3 > | BinImage |
| typedef itk::ImageRegionIterator < BinImage > | BinIteratorType |
| typedef itk::ImageRegionIteratorWithIndex < BinImage > | BinIteratorIndexType |
| typedef unsigned long | CountType |
Public Member Functions | |
| SimpleHistogram () | |
| ~SimpleHistogram () | |
| int | GetMin () |
| int | GetMax () |
| void | ComputeFromImage (Image::Pointer source) |
| float | GetRelativeBin (float start, float end) |
Protected Attributes | |
| CountType * | histogram |
| bool | valid |
| int | first |
| int | last |
| int | min |
| int | max |
| CountType | highest |
| double | invLogHighest |
Definition at line 38 of file QmitkTransferFunctionCanvas.h.
| typedef itk::Image<unsigned char, 3> mitk::SimpleHistogram::BinImage |
Definition at line 58 of file QmitkTransferFunctionCanvas.h.
| typedef itk::ImageRegionIteratorWithIndex< BinImage > mitk::SimpleHistogram::BinIteratorIndexType |
Definition at line 60 of file QmitkTransferFunctionCanvas.h.
| typedef itk::ImageRegionIterator< BinImage > mitk::SimpleHistogram::BinIteratorType |
Definition at line 59 of file QmitkTransferFunctionCanvas.h.
| typedef unsigned long mitk::SimpleHistogram::CountType |
Definition at line 62 of file QmitkTransferFunctionCanvas.h.
| typedef itk::Image<short, 3> mitk::SimpleHistogram::CTImage |
Definition at line 54 of file QmitkTransferFunctionCanvas.h.
| typedef itk::ImageRegionIteratorWithIndex< CTImage > mitk::SimpleHistogram::CTIteratorIndexType |
Definition at line 56 of file QmitkTransferFunctionCanvas.h.
| typedef itk::ImageRegionIterator< CTImage > mitk::SimpleHistogram::CTIteratorType |
Definition at line 55 of file QmitkTransferFunctionCanvas.h.
| mitk::SimpleHistogram::SimpleHistogram | ( | ) | [inline] |
Definition at line 42 of file QmitkTransferFunctionCanvas.h.
| mitk::SimpleHistogram::~SimpleHistogram | ( | ) | [inline] |
Definition at line 48 of file QmitkTransferFunctionCanvas.h.
| void mitk::SimpleHistogram::ComputeFromImage | ( | Image::Pointer | source ) |
Definition at line 26 of file QmitkTransferFunctionCanvas.cpp.
References first, highest, histogram, invLogHighest, last, QuadProgPP::log(), max, min, MITK_WARN, QuadProgPP::t(), and valid.
Referenced by mitk::SimpleHistogramCache::operator[]().
{
valid = false;
// dummy histogram
{
min=0;
max=1;
first=0;
last=1;
}
{
int typInt=0;
{
const std::type_info* typ=source->GetPixelType().GetTypeId();
if (*typ == typeid(unsigned char )) typInt=0;
else if(*typ == typeid(signed char )) typInt=1;
else if(*typ == typeid(unsigned short)) typInt=2;
else if(*typ == typeid(signed short )) typInt=3;
else
{
MITK_WARN << "SimpleHistogram currently only supports un/signed char/short";
return;
}
}
first=-32768; last=65535; // support at least full signed and unsigned short range
if(histogram)
delete histogram;
histogram = new CountType[last-first+1];
memset(histogram,0,sizeof(CountType)*(last-first+1));
highest = 0;
max = first - 1;
min = last + 1;
unsigned int num=1;
for(unsigned int r=0;r<source->GetDimension();r++)
num*=source->GetDimension(r);
// MITK_INFO << "building histogramm of integer image: 0=" << source->GetDimension(0) << " 1=" << source->GetDimension(1) << " 2=" << source->GetDimension(2) << " 3=" << source->GetDimension(3);
void *src=source->GetData();
do
{
int value;
switch(typInt)
{
case 0: { unsigned char *t=(unsigned char *)src; value=*t++; src=(void*)t; } break;
case 1: { signed char *t=( signed char *)src; value=*t++; src=(void*)t; } break;
case 2: { unsigned short *t=(unsigned short*)src; value=*t++; src=(void*)t; } break;
case 3: { signed short *t=( signed short*)src; value=*t++; src=(void*)t; } break;
}
if(value >= first && value <= last)
{
if(value < min) min = value;
if(value > max) max = value;
CountType tmp = ++histogram[value-first];
if(tmp > highest) highest = tmp;
}
}
while(--num);
//MITK_INFO << "histogramm computed: min=" << min << " max=" << max << " highestBin=" << highest << " samples=" << num;
}
invLogHighest = 1.0/log(double(highest));
valid = true;
}
| int mitk::SimpleHistogram::GetMax | ( | ) | [inline] |
Definition at line 87 of file QmitkTransferFunctionCanvas.h.
References QuadProgPP::max().
Referenced by QmitkTransferFunctionWidget::SetDataNode().
| int mitk::SimpleHistogram::GetMin | ( | ) | [inline] |
Definition at line 79 of file QmitkTransferFunctionCanvas.h.
References min.
Referenced by QmitkTransferFunctionWidget::SetDataNode().
| float mitk::SimpleHistogram::GetRelativeBin | ( | float | start, |
| float | end | ||
| ) |
Definition at line 103 of file QmitkTransferFunctionCanvas.cpp.
References QuadProgPP::log().
Referenced by QmitkTransferFunctionCanvas::PaintHistogram().
{
if( !valid )
return 0.0f;
int iLeft = floorf(left);
int iRight = ceilf(right);
/*
double sum = 0;
for( int r = 0 ; r < 256 ; r++)
{
int pos = left + (right-left) * r/255.0;
int posInArray = floorf(pos+0.5f) - first;
sum += float(log(double(histogram[posInArray])));
}
sum /= 256.0;
return float(sum*invLogHighest);
*/
CountType maximum = 0;
for( int i = iLeft; i <= iRight ; i++)
{
int posInArray = i - first;
if( histogram[posInArray] > maximum ) maximum = histogram[posInArray];
}
return float(log(double(maximum))*invLogHighest);
}
int mitk::SimpleHistogram::first [protected] |
Definition at line 70 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
CountType mitk::SimpleHistogram::highest [protected] |
Definition at line 74 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
CountType* mitk::SimpleHistogram::histogram [protected] |
Definition at line 66 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
double mitk::SimpleHistogram::invLogHighest [protected] |
Definition at line 75 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
int mitk::SimpleHistogram::last [protected] |
Definition at line 71 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
int mitk::SimpleHistogram::max [protected] |
Definition at line 73 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
int mitk::SimpleHistogram::min [protected] |
Definition at line 72 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
bool mitk::SimpleHistogram::valid [protected] |
Definition at line 68 of file QmitkTransferFunctionCanvas.h.
Referenced by ComputeFromImage().
1.7.2