22 #include "itkImageRegionIterator.h"
28 #include <itkLabelStatisticsImageFilter.h>
29 #include <itkMinimumMaximumImageCalculator.h>
34 this->SetNumberOfIndexedInputs(3);
35 this->SetNumberOfRequiredInputs(3);
46 this->SetNthInput(1, nonconstMask );
51 return this->GetInput(1);
56 Superclass::GenerateInputRequestedRegion();
68 itkDebugMacro(<<
"GenerateOutputInformation()");
70 output->Initialize(input->GetPixelType(), *input->GetTimeGeometry());
71 output->SetPropertyList(input->GetPropertyList()->Clone());
74 template <
typename TPixel,
unsigned int VImageDimension >
78 typedef itk::Image<TPixel, VImageDimension>
ImageType;
79 typedef itk::Image<int, VImageDimension> MaskType;
80 typedef itk::LabelStatisticsImageFilter<ImageType, MaskType> FilterType;
81 typedef itk::MinimumMaximumImageCalculator<ImageType> MinMaxComputerType;
90 minMaxComputer->SetImage(itkImage);
91 minMaxComputer->Compute();
94 labelStatisticsImageFilter->SetUseHistograms(
true);
95 labelStatisticsImageFilter->SetHistogramParameters(256, minMaxComputer->GetMinimum(),minMaxComputer->GetMaximum());
96 labelStatisticsImageFilter->SetInput( itkImage );
98 labelStatisticsImageFilter->SetLabelInput(itkMask0);
99 labelStatisticsImageFilter->Update();
100 double median0 = labelStatisticsImageFilter->GetMedian(1);
101 double mean0 = labelStatisticsImageFilter->GetMean(1);
102 double stddev = labelStatisticsImageFilter->GetSigma(1);
105 auto histo = labelStatisticsImageFilter->GetHistogram(1);
106 double maxFrequency=0;
107 for (
auto hIter=histo->Begin();hIter!=histo->End();++hIter)
109 if (maxFrequency < hIter.GetFrequency())
111 maxFrequency = hIter.GetFrequency();
112 modulo0 = (histo->GetBinMin(0,hIter.GetInstanceIdentifier()) + histo->GetBinMax(0,hIter.GetInstanceIdentifier())) / 2.0;
118 switch (m_CenterMode)
123 value0=median0;
break;
125 value0=modulo0;
break;
129 double scaling = stddev;
130 if (scaling < 0.0001)
133 itk::ImageRegionIterator<ImageType> inIter(itkImage, itkImage->GetLargestPossibleRegion());
134 itk::ImageRegionIterator<ImageType> outIter(outImage, outImage->GetLargestPossibleRegion());
135 while (! inIter.IsAtEnd())
137 TPixel value = inIter.Value();
138 outIter.Set((value - offset) / scaling);
virtual void SetRequestedRegionToLargestPossibleRegion() override
itk::SmartPointer< Self > Pointer
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
void SetMask(const mitk::Image *mask)
MRNormLinearStatisticBasedFilter()
void InternalComputeMask(itk::Image< TPixel, VImageDimension > *itkImage)
map::core::discrete::Elements< 3 >::InternalImageType ImageType
Image class for storing images.
~MRNormLinearStatisticBasedFilter()
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
const mitk::Image * GetMask() const
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
virtual void GenerateInputRequestedRegion() override
virtual void GenerateOutputInformation() override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.