33 if (source ==
nullptr)
50 if (typ == itk::ImageIOBase::UCHAR)
52 else if (typ == itk::ImageIOBase::CHAR)
54 else if (typ == itk::ImageIOBase::USHORT)
56 else if (typ == itk::ImageIOBase::SHORT)
58 else if (typ == itk::ImageIOBase::INT)
60 else if (typ == itk::ImageIOBase::UINT)
62 else if (typ == itk::ImageIOBase::LONG)
64 else if (typ == itk::ImageIOBase::ULONG)
66 else if (typ == itk::ImageIOBase::FLOAT)
68 else if (typ == itk::ImageIOBase::DOUBLE)
72 MITK_WARN <<
"Pixel type not supported by SimpleImageHistogram";
90 for (
unsigned int r = 0; r < source->
GetDimension(); r++)
97 const void *src = sourceAcc.
GetData();
107 unsigned char *t = (
unsigned char *)src;
114 signed char *t = (
signed char *)src;
121 unsigned short *t = (
unsigned short *)src;
128 signed short *t = (
signed short *)src;
135 signed int *t = (
signed int *)src;
142 unsigned int *t = (
unsigned int *)src;
149 signed long *t = (
signed long *)src;
156 unsigned long *t = (
unsigned long *)src;
163 float *t = (
float *)src;
170 double *t = (
double *)src;
190 <<
" samples=" << num;
203 int iLeft = floorf(left);
204 int iRight = ceilf(right);
222 for (
int i = iLeft; i <= iRight; i++)
224 int posInArray = i -
first;
236 SimpleHistogram *GetHistogram()
override {
return &histogram; }
237 SimpleImageHistogram histogram;
240 class UnstructuredGridHistogramCacheElement :
public SimpleHistogramCache::Element
243 void ComputeFromBaseData(BaseData *baseData)
override { histogram.ComputeFromBaseData(baseData); }
244 SimpleHistogram *GetHistogram()
override {
return &histogram; }
245 SimpleUnstructuredGridHistogram histogram;
250 BaseData *p_BaseData = sp_BaseData.GetPointer();
254 MITK_WARN <<
"SimpleHistogramCache::operator[] with null base data called";
258 Element *elementToUpdate =
nullptr;
262 for (
auto iter =
cache.begin(); iter !=
cache.end(); iter++)
267 if (p_tmp == p_BaseData)
277 goto recomputeElement;
288 if (dynamic_cast<Image *>(p_BaseData))
290 elementToUpdate =
new ImageHistogramCacheElement();
292 else if (dynamic_cast<UnstructuredGrid *>(p_BaseData))
294 elementToUpdate =
new UnstructuredGridHistogramCacheElement();
298 MITK_WARN <<
"not supported: " << p_BaseData->GetNameOfClass();
301 elementToUpdate->
baseData = p_BaseData;
302 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?)
const void * GetData() const
Gives const access to the data.
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...
void TrimCache(bool full=false)
Abstract superclass for histograms with double values. Classes which are deriving from this class can...
Image class for storing images.
itk::TimeStamp m_LastUpdateTime
int GetComponentType() const
Get the component type (the scalar (!) type). Each element may contain m_NumberOfComponents (more tha...
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
virtual unsigned long GetMTime() const override
Get the modified time of the last change of the contents this data object or its geometry.
virtual bool IsEmpty() const
Check whether object contains data (at least at one point in time), e.g., a set of points may be empt...
virtual SimpleHistogram * GetHistogram()=0
unsigned int GetDimension() const
Get dimension of the image.
ImageReadAccessor class to get locked read access for a particular image part.