diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step06.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step06.dox index 3a2726f266..9ca0db2336 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step06.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step06.dox @@ -1,118 +1,117 @@ /** \page Step06Page MITK Tutorial - Step 6: Use an interactive region-grower The source is now split among several files: \li \ref Step6.cpp "Step6.cpp" \li \ref Step6.h "Step6.h" \li \ref Step6RegionGrowing.txx "Step6RegionGrowing.txx" \li \ref Step6RegionGrowing1.cpp "Step6RegionGrowing1.cpp" \li \ref Step6RegionGrowing2.cpp "Step6RegionGrowing2.cpp" \li \ref Step6main.cpp "Step6main.cpp" \li Path to files used in this step: \n http://mitk.org/download/tutorial-data/Pic3D.nrrd (image) In this step the program is enhanced by the possibility to start a region-grower at interactively added points. We will see how MITK images can be accessed as ITK images. We now load the image file Pic3D.nrrd only since the surface will be the result of the region-growing. Add points in the image by pressing SHIFT+left mouse key, then adjust the thresholds and press 'Start region growing'. \imageMacro{step6_result.png,"",13.55} The class Step6 inherits from QWidget and provides methods for setting up the widgets. Step6RegionGrowing.cpp contains a method for performing the region-growing. Step6main.cpp contains main. Like in ITK and VTK class member names start with m_ followed by the proper member name starting with a capital letter (e.g. m_Tree). Function names start with capital letters. To learn more about style conventions in MITK read \ref StyleGuideAndNotesPage "The MITK Style Guide". \dontinclude Step6.cpp The widgets are initialized as in the previous steps but with an additional QVBox for a button to start the segmentation: \skipline Create controlsParent \until hlayout->addWidget(m_LineEditThresholdMax) This creates a button to start the segmentation and its clicked() signal is connected to the method StartRegionGrowing(): \dontinclude Step6.cpp -\skipline QPushButton* startButton +\skipline QPushButton *startButton \skipline connect(startButton \section AccessMTIKImagesAsITKImagesSection Access MITK images as ITK images ITK images are templated whereas mitk::Images are not. To use ITK filters with MITK images, we have to convert from MITK to ITK. To do so, first define an access method, which is templated as an ITK image is: \code template MyAccessMethod(itk::Image* itkImage) { ... } \endcode If you don't understand this template syntax, you should read any C++ text book. Understanding template syntax is crucial to successfully using ITK. To call this templated method with an (untemplated) mitk::Image, you can use the AccessByItk macro from mitkImageAccessByItk.h. This macro checks for the actual image type of the mitk::Image and does any neccessary conversions. Look into "Modules / Adaptor classes" for more information. \code AccessByItk(mitkImage, MyAccessMethod) \endcode \dontinclude Step6RegionGrowing.txx In this step our access method is called RegionGrowing() (defined in \ref Step6RegionGrowing.txx "Step6RegionGrowing.txx"): \skipline template -\until } -\until } +\until } //RegionGrowing() Additionally the access function has to be instantiated for all datatypes and two/three dimensions as some compilers have memory problems without this explicit instantiation, some even need instantiations in separate files for 2D/3D: \n For 2D in \ref Step6RegionGrowing1.cpp "Step6RegionGrowing1.cpp" : \dontinclude Step6RegionGrowing1.cpp -\skipline InstantiateAccessFunctionForFixedDimension_1 +\skipline InstantiateAccessFunctionForFixedDimension ... and for 3D in \ref Step6RegionGrowing2.cpp "Step6RegionGrowing2.cpp": \dontinclude Step6RegionGrowing2.cpp -\skipline InstantiateAccessFunctionForFixedDimension_1 +\skipline InstantiateAccessFunctionForFixedDimension \dontinclude Step6.cpp The method StartRegionGrowing() finally calls our access method RegionGrowing(): \skipline Step6::StartRegionGrowing \until } \section ConvertingITKMITKSection Converting ITK images to MITK images and vice versa In some cases it is useful to simply convert between ITK and MITK images. The direction ITK to MITK is easy, since mitk::Image can handle most data types. The direction MITK to ITK is more critical, since ITK images have to be instantiated with a fixed pixel type and fixed dimension at compile time. \li \code mitk::Image mitk::ImportItkImage(itk::Image<...>) \endcode \li \code mitk::CastToItkImage(mitkImage, itk::Image<...>) \endcode \section ConnectingMITKToVTKSection Connecting MITK images to VTK Images are not converted or copied: The data array is just accessed via an encapsulating VTK object. \li \code vtkImageData* mitk::Image::GetVtkImageData(int time = 0) \endcode \section SurfacesMITKToVTKSection MITK Surfaces to VTK and vice versa Again: not a conversion, just accessing. \li \code vtkPolyData* mitk::Surface::GetVtkPolyData(int time = 0) \endcode \li \code mitk::Surface::SetVtkPolyData(vtkPolyData*, int time = 0) \endcode \ref Step05Page "[Previous step]" \ref Step07Page "[Next step]" \ref TutorialPage "[Main tutorial page]" */ diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step07.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step07.dox index c3006dd5e0..91827ef670 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step07.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step07.dox @@ -1,21 +1,21 @@ /** \page Step07Page MITK Tutorial - Step 7: Convert result of region growing into a surface \li \ref Step7.cpp "Step7.cpp"\n \li \ref Step7.h "Step7.h"\n \li \ref Step7main.cpp "Step7main.cpp"\n \li Path to files used in this step: \n http://mitk.org/download/tutorial-data/Pic3D.nrrd (image) In this step the result of the previous step is converted into a surface by means of a VTK filter. Step7 inherits from Step6. It enhances the method StartRegionGrowing() by processing the result image. \dontinclude Step7.cpp - \skipline if(m_ResultImage + \skipline if (m_ResultImage \until } \ref Step06Page "[Previous step]" \ref Step08Page "[Next step]" \ref TutorialPage "[Main tutorial page]" */ diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step08.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step08.dox index 8d55a176e5..f5e9f8a3a3 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step08.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/Tutorial/Step08.dox @@ -1,25 +1,25 @@ /** \page Step08Page MITK Tutorial - Step 8: Use QmitkStdMultiWidget as widget \li \ref Step8.cpp "Step8.cpp"\n \li \ref Step8.h "Step8.h"\n \li \ref Step8main.cpp "Step8main.cpp"\n \li Path to files used in this step: \n http://mitk.org/download/tutorial-data/Pic3D.nrrd (image) In this step a QmitkStdMultiWidget is used. It offers four views of the data. From top left to bottom left the views are initialized as axial, sagittal and coronar. The bottom right view is initialized as 3D view. \image html step8_result.png Step8 inherits from Step6. The method SetupWidgets() is changed: A QmitkStdMultiWidget is used instead of one QmitkRenderWindow and two instances of QmitkSliceWidget. \dontinclude Step8.cpp \skipline Part Ia - \until EnableNavigationControllerEventListening + \until SetWidgetPlanesVisibility \ref Step07Page "[Previous step]" \ref Step09Page "[Next step]" */ diff --git a/Examples/Tutorial/Step6/Step6RegionGrowing.txx b/Examples/Tutorial/Step6/Step6RegionGrowing.txx index ee136d07ef..d8a7e739e4 100644 --- a/Examples/Tutorial/Step6/Step6RegionGrowing.txx +++ b/Examples/Tutorial/Step6/Step6RegionGrowing.txx @@ -1,93 +1,93 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "Step6.h" #include #include #include #include #include #include #include template void RegionGrowing(itk::Image *itkImage, Step6 *step6) { typedef itk::Image ImageType; typedef float InternalPixelType; typedef itk::Image InternalImageType; mitk::BaseGeometry *geometry = step6->m_FirstImage->GetGeometry(); // create itk::CurvatureFlowImageFilter for smoothing and set itkImage as input typedef itk::CurvatureFlowImageFilter CurvatureFlowFilter; typename CurvatureFlowFilter::Pointer smoothingFilter = CurvatureFlowFilter::New(); smoothingFilter->SetInput(itkImage); smoothingFilter->SetNumberOfIterations(4); smoothingFilter->SetTimeStep(0.0625); // create itk::ConnectedThresholdImageFilter and set filtered image as input typedef itk::ConnectedThresholdImageFilter RegionGrowingFilterType; typedef typename RegionGrowingFilterType::IndexType IndexType; typename RegionGrowingFilterType::Pointer regGrowFilter = RegionGrowingFilterType::New(); regGrowFilter->SetInput(smoothingFilter->GetOutput()); regGrowFilter->SetLower(step6->GetThresholdMin()); regGrowFilter->SetUpper(step6->GetThresholdMax()); // convert the points in the PointSet m_Seeds (in world-coordinates) to // "index" values, i.e. points in pixel coordinates, and add these as seeds // to the RegionGrower mitk::PointSet::PointsConstIterator pit, pend = step6->m_Seeds->GetPointSet()->GetPoints()->End(); IndexType seedIndex; for (pit = step6->m_Seeds->GetPointSet()->GetPoints()->Begin(); pit != pend; ++pit) { geometry->WorldToIndex(pit.Value(), seedIndex); regGrowFilter->AddSeed(seedIndex); } regGrowFilter->GetOutput()->Update(); mitk::Image::Pointer mitkImage = mitk::Image::New(); mitk::CastToMitkImage(regGrowFilter->GetOutput(), mitkImage); if (step6->m_ResultNode.IsNull()) { step6->m_ResultNode = mitk::DataNode::New(); step6->m_DataStorage->Add(step6->m_ResultNode); } step6->m_ResultNode->SetData(mitkImage); // set some additional properties step6->m_ResultNode->SetProperty("name", mitk::StringProperty::New("segmentation")); step6->m_ResultNode->SetProperty("binary", mitk::BoolProperty::New(true)); step6->m_ResultNode->SetProperty("color", mitk::ColorProperty::New(1.0, 0.0, 0.0)); step6->m_ResultNode->SetProperty("volumerendering", mitk::BoolProperty::New(true)); step6->m_ResultNode->SetProperty("layer", mitk::IntProperty::New(1)); mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); mitk::LevelWindow levelwindow; levelwindow.SetAuto(mitkImage); levWinProp->SetLevelWindow(levelwindow); step6->m_ResultNode->SetProperty("levelwindow", levWinProp); step6->m_ResultImage = static_cast(step6->m_ResultNode->GetData()); -} +} //RegionGrowing() /** \example Step6RegionGrowing.txx */