Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageVtkMapper2DLevelWindowTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 // MITK
19 #include "mitkTestingMacros.h"
20 #include <mitkLevelWindowPreset.h>
22 
23 // VTK
24 #include <vtkRegressionTestImage.h>
25 
26 int mitkImageVtkMapper2DLevelWindowTest(int argc, char *argv[])
27 {
28  // load all arguments into a datastorage, take last argument as reference rendering
29  // setup a renderwindow of fixed size X*Y
30  // render the datastorage
31  // compare rendering to reference image
32  MITK_TEST_BEGIN("mitkImageVtkMapper2DTest")
33 
34  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
35  // chose a level window: here we randomly chosen the blood preset.
37  bool loadedPreset = levelWindowPreset->LoadPreset();
38  MITK_TEST_CONDITION_REQUIRED(loadedPreset == true, "Testing if level window preset could be loaded");
39  double level = levelWindowPreset->getLevel("Blood");
40  double window = levelWindowPreset->getWindow("Blood");
41  levelWindowPreset->Delete();
42  // apply level window to all images
43  renderingHelper.SetImageProperty("levelwindow", mitk::LevelWindowProperty::New(mitk::LevelWindow(level, window)));
44  // for now this test renders Sagittal
46 
47  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper
48  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true,
49  "CompareRenderWindowAgainstReference test result positive?");
50 
51  // use this to generate a reference screenshot or save the file:
52  if (false)
53  {
54  renderingHelper.SaveReferenceScreenShot("/media/hdd/thomasHdd/Pictures/tmp/output1.png");
55  }
56 
57  MITK_TEST_END();
58 }
void SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection)
Set the view direction of the renderwindow (e.g. sagittal, coronal, axial)
static Pointer New()
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
void SaveReferenceScreenShot(std::string fileName)
SaveReferenceScreenShot Convenience method to save a reference screen shot.
bool CompareRenderWindowAgainstReference(int argc, char *argv[], double threshold=10.0)
CompareRenderWindowAgainstReference Convenience method to compare the image rendered in the internal ...
void SetImageProperty(const char *propertyKey, mitk::BaseProperty *property)
This method set the property of the member datastorage.
The LevelWindow class Class to store level/window values.
#define MITK_TEST_CONDITION(COND, MSG)
int mitkImageVtkMapper2DLevelWindowTest(int argc, char *argv[])
double getWindow(std::string window)
static LevelWindowPreset * New()
and MITK_TEST_END()
double getLevel(std::string name)