25 #include <itkTestingComparisonImageFilter.h>
29 this->SetNumberOfRequiredInputs(2);
36 m_CompareDetails.m_MaximumDifference = 0.0f;
38 m_CompareDetails.m_MeanDifference = 0.0f;
39 m_CompareDetails.m_TotalDifference = 0.0f;
40 m_CompareDetails.m_PixelsWithDifference = 0;
41 m_CompareDetails.m_FilterCompleted =
false;
42 m_CompareDetails.m_ExceptionMessage =
"";
63 this->ResetCompareResultsToInitial();
66 mcComparator->SetTestImage(input1);
67 mcComparator->SetValidImage(input2);
68 mcComparator->SetCompareFilterResult(&m_CompareDetails);
69 mcComparator->SetTolerance(m_Tolerance);
70 mcComparator->Update();
72 m_CompareResult = mcComparator->GetResult();
76 bool mitk::CompareImageDataFilter::GetResult(
size_t threshold)
83 if (m_CompareDetails.m_PixelsWithDifference > threshold)
91 template <
typename TPixel,
unsigned int VImageDimension>
102 typedef itk::Testing::ComparisonImageFilter<InputImageType, OutputImageType> CompareFilterType;
104 compare_filter->SetTestInput(itkImage1);
105 compare_filter->SetValidInput(itk_reference);
106 compare_filter->SetDifferenceThreshold(m_Tolerance);
110 compare_filter->Update();
112 catch (
const itk::ExceptionObject &e)
114 m_CompareDetails.m_FilterCompleted =
false;
115 m_CompareDetails.m_ExceptionMessage = e.what();
119 m_CompareResult =
false;
124 m_CompareResult =
true;
125 m_CompareDetails.m_FilterCompleted =
true;
127 m_CompareDetails.m_MaximumDifference = compare_filter->GetMaximumDifference();
128 m_CompareDetails.m_MinimumDifference = compare_filter->GetMinimumDifference();
129 m_CompareDetails.m_MeanDifference = compare_filter->GetMeanDifference();
130 m_CompareDetails.m_TotalDifference = compare_filter->GetTotalDifference();
131 m_CompareDetails.m_PixelsWithDifference = compare_filter->GetNumberOfPixelsWithDifferences();
134 this->SetOutput(MakeNameFromOutputIndex(0), output.GetPointer());
itk::SmartPointer< Self > Pointer
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
void EstimateValueDifference(const itk::Image< TPixel, VImageDimension > *itkImage1, const mitk::Image *referenceImage)
#define AccessByItk_1(mitkImage, itkImageTypeFunction, arg1)
Image::Pointer GrabItkImageMemory(itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.
itk::Image< double, 3 > InputImageType
Image class for storing images.
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
vcl_size_t GetNumberOfComponents() const
Get the number of components of which each element consists.
void ResetCompareResultsToInitial()
Method resets the compare detail memeber struct to its initial state.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.