Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageVtkMapper2DLookupTableTest.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 <mitkIOUtil.h>
21 #include <mitkLookupTable.h>
25 
26 // VTK
27 #include <vtkLookupTable.h>
28 
29 int mitkImageVtkMapper2DLookupTableTest(int argc, char *argv[])
30 {
31  // load all arguments into a datastorage, take last argument as reference rendering
32  // setup a renderwindow of fixed size X*Y
33  // render the datastorage
34  // compare rendering to reference image
35  MITK_TEST_BEGIN("mitkImageVtkMapper2DLookupTableTest")
36 
37  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
38 
39  // define an arbitrary lookupTable
40  vtkSmartPointer<vtkLookupTable> lookupTable = vtkSmartPointer<vtkLookupTable>::New();
41  // use linear interpolation
42  lookupTable->SetRampToLinear();
43  // use the scalar range of the image to have a nice lookuptable
44  lookupTable->SetTableRange(0, 255);
45  lookupTable->Build();
46 
47  // Fill in a few known colors, the rest will be generated
48  lookupTable->SetTableValue(0, 1.0, 0.0, 0.0, 1.0); // map from red
49  lookupTable->SetTableValue(255, 0.0, 0.0, 1.0, 1.0); // to blue
50 
52  myLookupTable->SetVtkLookupTable(lookupTable);
53 
54  // set the rendering mode to use the transfer function
55  renderingHelper.SetImageProperty("Image Rendering.Mode",
57  // set the property for the image
58  renderingHelper.SetImageProperty("LookupTable", mitk::LookupTableProperty::New(myLookupTable));
59 
60  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper
61  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv, 20.0) == true,
62  "CompareRenderWindowAgainstReference test result positive?");
63 
64  // use this to generate a reference screenshot or save the file:
65  if (false)
66  {
67  renderingHelper.SaveReferenceScreenShot("/media/hdd/thomasHdd/Pictures/tmp/output.png");
68  }
69 
70  MITK_TEST_END();
71 }
int mitkImageVtkMapper2DLookupTableTest(int argc, char *argv[])
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.
static Pointer New()
#define MITK_TEST_CONDITION(COND, MSG)
and MITK_TEST_END()
static Pointer New()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.