22 #include <itkComposeImageFilter.h>
23 #include <itkEventObject.h>
24 #include <itkImageDuplicator.h>
25 #include <itkImageIterator.h>
30 CPPUNIT_TEST_SUITE(mitkLevelWindowManagerCppUnitTestSuite);
32 CPPUNIT_TEST_SUITE_END();
44 typedef itk::ImageRegionIterator<ImageType> ImageIteratorType;
45 typedef itk::ImageDuplicator<ImageType> DuplicatorType;
46 typedef itk::ComposeImageFilter<ImageType> CompositeFilterType;
50 ImageType::IndexType start;
52 ImageType::SizeType size;
54 ImageType::RegionType region;
56 region.SetIndex(start);
57 imageComponent1->SetRegions(region);
58 imageComponent1->Allocate();
61 duplicator->SetInputImage(imageComponent1);
66 ImageIteratorType iterator1(imageComponent1, imageComponent1->GetLargestPossibleRegion());
67 iterator1.GoToBegin();
69 while (!iterator1.IsAtEnd())
71 iterator1.Set((
double)i);
76 ImageIteratorType iterator2(imageComponent2, imageComponent2->GetLargestPossibleRegion());
77 iterator2.GoToBegin();
79 while (!iterator2.IsAtEnd())
81 iterator2.Set((
double)i);
88 compositeFilter->SetInput(0, imageComponent1);
89 compositeFilter->SetInput(1, imageComponent2);
90 compositeFilter->Update();
107 manager->SetDataStorage(ds);
109 catch (std::exception &e)
115 node->SetData(image);
118 node->SetBoolProperty(
"selected",
true);
119 node->SetIntProperty(
"Image.Displayed Component", component);
122 node->GetLevelWindow(levelWindow);
126 void TestMultiComponentRescaling()
129 mitk::LevelWindow imageComponent1LevelWindow = getLevelWindowForImage(m_mitkImageComponent1, 0);
130 mitk::LevelWindow imageComponent2LevelWindow = getLevelWindowForImage(m_mitkImageComponent2, 0);
132 mitk::LevelWindow multiComponentImageLevelWindow = getLevelWindowForImage(m_mitkMultiComponentImage, 1);
136 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"default lower bounds equal",
140 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"default upper bounds equal",
144 CPPUNIT_ASSERT_EQUAL_MESSAGE(
145 "range equal", imageComponent2LevelWindow.
GetRange(), multiComponentImageLevelWindow.
GetRange());
itk::SmartPointer< Self > Pointer
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
ScalarType GetDefaultLowerBound() const
ScalarType GetDefaultUpperBound() const
The LevelWindow class Class to store level/window values.
map::core::discrete::Elements< 3 >::InternalImageType ImageType
Image class for storing images.
Test fixture for parameterized tests.
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
ScalarType GetRange() const
returns the size of the grey value range
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.