28 auto *source =
dynamic_cast<Image *
>(src);
29 if (source ==
nullptr)
31 else if (source->IsEmpty())
45 const int typ = source->GetPixelType().GetComponentType();
46 if (typ == itk::ImageIOBase::UCHAR)
48 else if (typ == itk::ImageIOBase::CHAR)
50 else if (typ == itk::ImageIOBase::USHORT)
52 else if (typ == itk::ImageIOBase::SHORT)
54 else if (typ == itk::ImageIOBase::INT)
56 else if (typ == itk::ImageIOBase::UINT)
58 else if (typ == itk::ImageIOBase::LONG)
60 else if (typ == itk::ImageIOBase::ULONG)
62 else if (typ == itk::ImageIOBase::FLOAT)
64 else if (typ == itk::ImageIOBase::DOUBLE)
68 MITK_WARN <<
"Pixel type not supported by SimpleImageHistogram";
86 for (
unsigned int r = 0; r < source->GetDimension(); r++)
87 num *= source->GetDimension(r);
93 const void *src = sourceAcc.
GetData();
103 auto *t = (
unsigned char *)src;
110 auto *t = (
signed char *)src;
117 auto *t = (
unsigned short *)src;
124 auto *t = (
signed short *)src;
131 auto *t = (
signed int *)src;
138 auto *t = (
unsigned int *)src;
145 auto *t = (
signed long *)src;
152 auto *t = (
unsigned long *)src;
159 auto *t = (
float *)src;
166 auto *t = (
double *)src;
186 <<
" samples=" << num;
199 int iLeft = floorf(left);
200 int iRight = ceilf(right);
218 for (
int i = iLeft; i <= iRight; i++)
220 int posInArray = i -
first;
246 BaseData *p_BaseData = sp_BaseData.GetPointer();
250 MITK_WARN <<
"SimpleHistogramCache::operator[] with null base data called";
254 Element *elementToUpdate =
nullptr;
258 for (
auto iter = cache.begin(); iter != cache.end(); iter++)
263 if (p_tmp == p_BaseData)
273 goto recomputeElement;
284 if (dynamic_cast<Image *>(p_BaseData))
286 elementToUpdate =
new ImageHistogramCacheElement();
288 else if (dynamic_cast<UnstructuredGrid *>(p_BaseData))
290 elementToUpdate =
new UnstructuredGridHistogramCacheElement();
294 MITK_WARN <<
"not supported: " << p_BaseData->GetNameOfClass();
297 elementToUpdate->
baseData = p_BaseData;
298 cache.push_front(elementToUpdate);
SimpleHistogram * operator[](BaseData::Pointer sp_BaseData)
mitk::WeakPointer< BaseData > baseData
Base of all data objects.
virtual void ComputeFromBaseData(BaseData *baseData)=0
float GetRelativeBin(double start, double end) const override
TODO: (What should this method do?)
DataCollection - Class to facilitate loading/accessing structured data.
void ComputeFromBaseData(BaseData *source) override
Creates a new histogram out the source which must be an image. Method does nothing if the image is in...
Abstract superclass for histograms with double values. Classes which are deriving from this class can...
Image class for storing images.
itk::TimeStamp m_LastUpdateTime
unsigned long GetMTime() const override
Get the modified time of the last change of the contents this data object or its geometry.
virtual SimpleHistogram * GetHistogram()=0
ImageReadAccessor class to get locked read access for a particular image part.
const void * GetData() const
Gives const access to the data.