22 #include <itkThresholdImageFilter.h>
36 template <
typename TPixel,
unsigned int VDimensions>
43 typedef itk::Image<TPixel, VDimensions> OutputImageType;
44 typedef itk::ThresholdImageFilter<InputImageType> ThresholdFilterType;
47 thresholder->SetInput(image);
48 thresholder->ThresholdOutside(th[0], th[1]);
49 thresholder->Update();
55 catch (itk::ExceptionObject &)
66 template <
typename TPixel>
70 const unsigned int dimensions[3] = {3, 3, 3};
71 auto image_data =
new TPixel[27];
74 auto ground_truth =
new TPixel[27];
75 double threshold[2] = {90.0, 180.0};
78 for (
unsigned int i = 0; i < 27; i++)
80 image_data[i] =
static_cast<TPixel
>(i * 10);
83 if (image_data[i] >= threshold[0] && image_data[i] <= threshold[1])
84 ground_truth[i] =
static_cast<TPixel
>(i * 10);
88 input->Initialize(mitk::MakeScalarPixelType<TPixel>(), 3, dimensions);
89 input->SetImportVolume(image_data);
97 const TPixel *output_data = readAccessor.
GetData();
100 for (
unsigned int i = 0; i < 27; i++)
102 equal &= (ground_truth[i] == output_data[i]);
105 MITK_INFO <<
" :: At position " << i <<
" : " << ground_truth[i] <<
" ? " << output_data[i] <<
"\n";
119 Assert_ItkImportWithinAccessByItkSucceded_ReturnsTrue<short>();
120 Assert_ItkImportWithinAccessByItkSucceded_ReturnsTrue<float>();
121 Assert_ItkImportWithinAccessByItkSucceded_ReturnsTrue<unsigned char>();
122 Assert_ItkImportWithinAccessByItkSucceded_ReturnsTrue<int>();
itk::SmartPointer< Self > Pointer
Gives locked and index-based read access for a particular image part. The class provides several set-...
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
bool Assert_ItkImportWithinAccessByItkSucceded_ReturnsTrue()
[ItkThresholdFilter]
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
#define MITK_TEST_CONDITION(COND, MSG)
#define MITK_TEST_FAILED_MSG(MSG)
Fail and finish test with message MSG.
const TPixel * GetData() const
Gives const access to the data.
static void ItkThresholdFilter(const itk::Image< TPixel, VDimensions > *image, mitk::Image::Pointer &output, const double th[])
[ItkThresholdFilter]
#define AccessByItk_2(mitkImage, itkImageTypeFunction, arg1, arg2)
int mitkGrabItkImageMemoryTest(int, char *[])
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.