diff --git a/Core/Code/Testing/mitkOverwriteSliceFilterTest.cpp b/Core/Code/Testing/mitkOverwriteSliceFilterTest.cpp index 693419aa7a..7a8fbb2b72 100644 --- a/Core/Code/Testing/mitkOverwriteSliceFilterTest.cpp +++ b/Core/Code/Testing/mitkOverwriteSliceFilterTest.cpp @@ -1,392 +1,392 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 7837 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include #include #include #include #include #include #include #include #include int VolumeSize = 128; static void OverwriteByPointerTest(mitk::Image* workingImage, mitk::Image* refImg) { - /* ============= setup plane ============*/ - int sliceindex = 55;//rand() % 32; - bool isFrontside = true; - bool isRotated = false; - - mitk::PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New(); - plane->InitializeStandardPlane(workingImage->GetGeometry(), mitk::PlaneGeometry::Transversal, sliceindex, isFrontside, isRotated); - mitk::Point3D origin = plane->GetOrigin(); - mitk::Vector3D normal; - normal = plane->GetNormal(); - normal.Normalize(); - origin += normal * 0.5;//pixelspacing is 1, so half the spacing is 0.5 - plane->SetOrigin(origin); - - - - /* ============= extract slice ============*/ - vtkSmartPointer resliceIdx = vtkSmartPointer::New(); - mitk::ExtractSliceFilter::Pointer slicer = mitk::ExtractSliceFilter::New(resliceIdx); - slicer->SetInput(workingImage); - slicer->SetWorldGeometry(plane); - slicer->SetVtkOutputRequest(true); - slicer->Modified(); - slicer->Update(); - - vtkSmartPointer slice = vtkSmartPointer::New(); - slice = slicer->GetVtkOutput(); - - - - /* ============= overwrite slice ============*/ - resliceIdx->SetOverwriteMode(true); - resliceIdx->Modified(); - slicer->Modified(); - slicer->Update();//implicit overwrite - - - - /* ============= check ref == working ============*/ - bool areSame = true; - mitk::Index3D id; - id[0] = id[1] = id[2] = 0; - for (int x = 0; x < VolumeSize; ++x){ - id[0] = x; - for (int y = 0; y < VolumeSize; ++y){ - id[1] = y; - for (int z = 0; z < VolumeSize; ++z){ - id[2] = z; - areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); - if(!areSame) - goto stop; - } - } - } + /* ============= setup plane ============*/ + int sliceindex = 55;//rand() % 32; + bool isFrontside = true; + bool isRotated = false; + + mitk::PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New(); + plane->InitializeStandardPlane(workingImage->GetGeometry(), mitk::PlaneGeometry::Transversal, sliceindex, isFrontside, isRotated); + mitk::Point3D origin = plane->GetOrigin(); + mitk::Vector3D normal; + normal = plane->GetNormal(); + normal.Normalize(); + origin += normal * 0.5;//pixelspacing is 1, so half the spacing is 0.5 + plane->SetOrigin(origin); + + + + /* ============= extract slice ============*/ + vtkSmartPointer resliceIdx = vtkSmartPointer::New(); + mitk::ExtractSliceFilter::Pointer slicer = mitk::ExtractSliceFilter::New(resliceIdx); + slicer->SetInput(workingImage); + slicer->SetWorldGeometry(plane); + slicer->SetVtkOutputRequest(true); + slicer->Modified(); + slicer->Update(); + + vtkSmartPointer slice = vtkSmartPointer::New(); + slice = slicer->GetVtkOutput(); + + + + /* ============= overwrite slice ============*/ + resliceIdx->SetOverwriteMode(true); + resliceIdx->Modified(); + slicer->Modified(); + slicer->Update();//implicit overwrite + + + + /* ============= check ref == working ============*/ + bool areSame = true; + mitk::Index3D id; + id[0] = id[1] = id[2] = 0; + for (int x = 0; x < VolumeSize; ++x){ + id[0] = x; + for (int y = 0; y < VolumeSize; ++y){ + id[1] = y; + for (int z = 0; z < VolumeSize; ++z){ + id[2] = z; + areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); + if(!areSame) + goto stop; + } + } + } stop: - MITK_TEST_CONDITION(areSame,"comparing images [orthogonal]"); + MITK_TEST_CONDITION(areSame,"comparing images [orthogonal]"); - /* ============= edit slice ============*/ - int idX = std::abs(VolumeSize-59); - int idY = std::abs(VolumeSize-23); - int idZ = 0; - int component = 0; - double val = 33.0; + /* ============= edit slice ============*/ + int idX = std::abs(VolumeSize-59); + int idY = std::abs(VolumeSize-23); + int idZ = 0; + int component = 0; + double val = 33.0; - slice->SetScalarComponentFromDouble(idX,idY,idZ,component,val); + slice->SetScalarComponentFromDouble(idX,idY,idZ,component,val); - /* ============= overwrite slice ============*/ + /* ============= overwrite slice ============*/ - vtkSmartPointer resliceIdx2 = vtkSmartPointer::New(); - resliceIdx2->SetOverwriteMode(true); - resliceIdx2->SetInputSlice(slice); - mitk::ExtractSliceFilter::Pointer slicer2 = mitk::ExtractSliceFilter::New(resliceIdx2); - slicer2->SetInput(workingImage); - slicer2->SetWorldGeometry(plane); - slicer2->SetVtkOutputRequest(true); - slicer2->Modified(); - slicer2->Update(); - + vtkSmartPointer resliceIdx2 = vtkSmartPointer::New(); + resliceIdx2->SetOverwriteMode(true); + resliceIdx2->SetInputSlice(slice); + mitk::ExtractSliceFilter::Pointer slicer2 = mitk::ExtractSliceFilter::New(resliceIdx2); + slicer2->SetInput(workingImage); + slicer2->SetWorldGeometry(plane); + slicer2->SetVtkOutputRequest(true); + slicer2->Modified(); + slicer2->Update(); + - /* ============= check ============*/ - areSame = true; + /* ============= check ============*/ + areSame = true; - int x,y,z; + int x,y,z; - for ( x = 0; x < VolumeSize; ++x){ - id[0] = x; - for ( y = 0; y < VolumeSize; ++y){ - id[1] = y; - for ( z = 0; z < VolumeSize; ++z){ - id[2] = z; - areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); - if(!areSame) - goto stop2; - } - } - } + for ( x = 0; x < VolumeSize; ++x){ + id[0] = x; + for ( y = 0; y < VolumeSize; ++y){ + id[1] = y; + for ( z = 0; z < VolumeSize; ++z){ + id[2] = z; + areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); + if(!areSame) + goto stop2; + } + } + } stop2: - //MITK_INFO << "index: [" << x << ", " << y << ", " << z << "]"; - MITK_TEST_CONDITION(x==idX && y==idY && z==sliceindex,"overwrited the right index [orthogonal]"); + //MITK_INFO << "index: [" << x << ", " << y << ", " << z << "]"; + MITK_TEST_CONDITION(x==idX && y==idY && z==sliceindex,"overwrited the right index [orthogonal]"); } static void OverwriteByPointerForObliquePlaneTest(mitk::Image* workingImage, mitk::Image* refImg) { /*==============TEST WITHOUT MITK CONVERTION=============================*/ - /* ============= setup plane ============*/ - int sliceindex = (int)(VolumeSize/2);//rand() % 32; - bool isFrontside = true; - bool isRotated = false; - - mitk::PlaneGeometry::Pointer obliquePlane = mitk::PlaneGeometry::New(); - obliquePlane->InitializeStandardPlane(workingImage->GetGeometry(), mitk::PlaneGeometry::Transversal, sliceindex, isFrontside, isRotated); - mitk::Point3D origin = obliquePlane->GetOrigin(); - mitk::Vector3D normal; - normal = obliquePlane->GetNormal(); - normal.Normalize(); - origin += normal * 0.5;//pixelspacing is 1, so half the spacing is 0.5 - obliquePlane->SetOrigin(origin); - - mitk::Vector3D rotationVector = obliquePlane->GetAxisVector(0); - rotationVector.Normalize(); - - float degree = 45.0; - - mitk::RotationOperation* op = new mitk::RotationOperation(mitk::OpROTATE, obliquePlane->GetCenter(), rotationVector, degree); - obliquePlane->ExecuteOperation(op); - delete op; - - - /* ============= extract slice ============*/ - mitk::ExtractSliceFilter::Pointer slicer = mitk::ExtractSliceFilter::New(); - slicer->SetInput(workingImage); - slicer->SetWorldGeometry(obliquePlane); - slicer->SetVtkOutputRequest(true); - slicer->Modified(); - slicer->Update(); - - vtkSmartPointer slice = vtkSmartPointer::New(); - slice = slicer->GetVtkOutput(); - - - - /* ============= overwrite slice ============*/ - vtkSmartPointer resliceIdx = vtkSmartPointer::New(); - mitk::ExtractSliceFilter::Pointer overwriter = mitk::ExtractSliceFilter::New(resliceIdx); - resliceIdx->SetOverwriteMode(true); - resliceIdx->SetInputSlice(slice); - resliceIdx->Modified(); - overwriter->SetInput(workingImage); - overwriter->SetWorldGeometry(obliquePlane); - overwriter->SetVtkOutputRequest(true); - overwriter->Modified(); - overwriter->Update(); - - - - /* ============= check ref == working ============*/ - bool areSame = true; - mitk::Index3D id; - id[0] = id[1] = id[2] = 0; - for (int x = 0; x < VolumeSize; ++x){ - id[0] = x; - for (int y = 0; y < VolumeSize; ++y){ - id[1] = y; - for (int z = 0; z < VolumeSize; ++z){ - id[2] = z; - areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); - if(!areSame) - goto stop; - } - } - } + /* ============= setup plane ============*/ + int sliceindex = (int)(VolumeSize/2);//rand() % 32; + bool isFrontside = true; + bool isRotated = false; + + mitk::PlaneGeometry::Pointer obliquePlane = mitk::PlaneGeometry::New(); + obliquePlane->InitializeStandardPlane(workingImage->GetGeometry(), mitk::PlaneGeometry::Transversal, sliceindex, isFrontside, isRotated); + mitk::Point3D origin = obliquePlane->GetOrigin(); + mitk::Vector3D normal; + normal = obliquePlane->GetNormal(); + normal.Normalize(); + origin += normal * 0.5;//pixelspacing is 1, so half the spacing is 0.5 + obliquePlane->SetOrigin(origin); + + mitk::Vector3D rotationVector = obliquePlane->GetAxisVector(0); + rotationVector.Normalize(); + + float degree = 45.0; + + mitk::RotationOperation* op = new mitk::RotationOperation(mitk::OpROTATE, obliquePlane->GetCenter(), rotationVector, degree); + obliquePlane->ExecuteOperation(op); + delete op; + + + /* ============= extract slice ============*/ + mitk::ExtractSliceFilter::Pointer slicer = mitk::ExtractSliceFilter::New(); + slicer->SetInput(workingImage); + slicer->SetWorldGeometry(obliquePlane); + slicer->SetVtkOutputRequest(true); + slicer->Modified(); + slicer->Update(); + + vtkSmartPointer slice = vtkSmartPointer::New(); + slice = slicer->GetVtkOutput(); + + + + /* ============= overwrite slice ============*/ + vtkSmartPointer resliceIdx = vtkSmartPointer::New(); + mitk::ExtractSliceFilter::Pointer overwriter = mitk::ExtractSliceFilter::New(resliceIdx); + resliceIdx->SetOverwriteMode(true); + resliceIdx->SetInputSlice(slice); + resliceIdx->Modified(); + overwriter->SetInput(workingImage); + overwriter->SetWorldGeometry(obliquePlane); + overwriter->SetVtkOutputRequest(true); + overwriter->Modified(); + overwriter->Update(); + + + + /* ============= check ref == working ============*/ + bool areSame = true; + mitk::Index3D id; + id[0] = id[1] = id[2] = 0; + for (int x = 0; x < VolumeSize; ++x){ + id[0] = x; + for (int y = 0; y < VolumeSize; ++y){ + id[1] = y; + for (int z = 0; z < VolumeSize; ++z){ + id[2] = z; + areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); + if(!areSame) + goto stop; + } + } + } stop: - MITK_TEST_CONDITION(areSame,"comparing images (no mitk convertion) [oblique]"); + MITK_TEST_CONDITION(areSame,"comparing images (no mitk convertion) [oblique]"); /*==============TEST WITH MITK CONVERTION=============================*/ - /* ============= extract slice ============*/ - mitk::ExtractSliceFilter::Pointer slicer2 = mitk::ExtractSliceFilter::New(); - slicer2->SetInput(workingImage); - slicer2->SetWorldGeometry(obliquePlane); - slicer2->Modified(); - slicer2->Update(); - - - mitk::Image::Pointer sliceInMitk = slicer2->GetOutput(); - vtkSmartPointer slice2 = vtkSmartPointer::New(); - slice2 = sliceInMitk->GetVtkImageData(); - - - /* ============= overwrite slice ============*/ - vtkSmartPointer resliceIdx2 = vtkSmartPointer::New(); - mitk::ExtractSliceFilter::Pointer overwriter2 = mitk::ExtractSliceFilter::New(resliceIdx2); - resliceIdx2->SetOverwriteMode(true); - resliceIdx2->SetInputSlice(slice2); - resliceIdx2->Modified(); - overwriter2->SetInput(workingImage); - overwriter2->SetWorldGeometry(obliquePlane); - overwriter2->SetVtkOutputRequest(true); - overwriter2->Modified(); - overwriter2->Update(); - - - - /* ============= check ref == working ============*/ - areSame = true; - id[0] = id[1] = id[2] = 0; - for (int x = 0; x < VolumeSize; ++x){ - id[0] = x; - for (int y = 0; y < VolumeSize; ++y){ - id[1] = y; - for (int z = 0; z < VolumeSize; ++z){ - id[2] = z; - areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); - if(!areSame) - goto stop2; - } - } - } + /* ============= extract slice ============*/ + mitk::ExtractSliceFilter::Pointer slicer2 = mitk::ExtractSliceFilter::New(); + slicer2->SetInput(workingImage); + slicer2->SetWorldGeometry(obliquePlane); + slicer2->Modified(); + slicer2->Update(); + + + mitk::Image::Pointer sliceInMitk = slicer2->GetOutput(); + vtkSmartPointer slice2 = vtkSmartPointer::New(); + slice2 = sliceInMitk->GetVtkImageData(); + + + /* ============= overwrite slice ============*/ + vtkSmartPointer resliceIdx2 = vtkSmartPointer::New(); + mitk::ExtractSliceFilter::Pointer overwriter2 = mitk::ExtractSliceFilter::New(resliceIdx2); + resliceIdx2->SetOverwriteMode(true); + resliceIdx2->SetInputSlice(slice2); + resliceIdx2->Modified(); + overwriter2->SetInput(workingImage); + overwriter2->SetWorldGeometry(obliquePlane); + overwriter2->SetVtkOutputRequest(true); + overwriter2->Modified(); + overwriter2->Update(); + + + + /* ============= check ref == working ============*/ + areSame = true; + id[0] = id[1] = id[2] = 0; + for (int x = 0; x < VolumeSize; ++x){ + id[0] = x; + for (int y = 0; y < VolumeSize; ++y){ + id[1] = y; + for (int z = 0; z < VolumeSize; ++z){ + id[2] = z; + areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); + if(!areSame) + goto stop2; + } + } + } stop2: - MITK_TEST_CONDITION(areSame,"comparing images (with mitk convertion) [oblique]"); + MITK_TEST_CONDITION(areSame,"comparing images (with mitk convertion) [oblique]"); /*==============TEST EDIT WITHOUT MITK CONVERTION=============================*/ - /* ============= edit slice ============*/ - int idX = std::abs(VolumeSize-59); - int idY = std::abs(VolumeSize-23); - int idZ = 0; - int component = 0; - double val = 33.0; - - slice->SetScalarComponentFromDouble(idX,idY,idZ,component,val); - - mitk::Vector3D indx; - indx[0] = idX; indx[1] = idY; indx[2] = idZ; - sliceInMitk->GetGeometry()->IndexToWorld(indx, indx); - - /* ============= overwrite slice ============*/ - - vtkSmartPointer resliceIdx3 = vtkSmartPointer::New(); - resliceIdx3->SetOverwriteMode(true); - resliceIdx3->SetInputSlice(slice); - mitk::ExtractSliceFilter::Pointer overwriter3 = mitk::ExtractSliceFilter::New(resliceIdx3); - overwriter3->SetInput(workingImage); - overwriter3->SetWorldGeometry(obliquePlane); - overwriter3->SetVtkOutputRequest(true); - overwriter3->Modified(); - overwriter3->Update(); - - - - - /* ============= check ============*/ - areSame = true; - - int x,y,z; - - for ( x = 0; x < VolumeSize; ++x){ - id[0] = x; - for ( y = 0; y < VolumeSize; ++y){ - id[1] = y; - for ( z = 0; z < VolumeSize; ++z){ - id[2] = z; - areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); - if(!areSame) - goto stop3; - } - } - } + /* ============= edit slice ============*/ + int idX = std::abs(VolumeSize-59); + int idY = std::abs(VolumeSize-23); + int idZ = 0; + int component = 0; + double val = 33.0; + + slice->SetScalarComponentFromDouble(idX,idY,idZ,component,val); + + mitk::Vector3D indx; + indx[0] = idX; indx[1] = idY; indx[2] = idZ; + sliceInMitk->GetGeometry()->IndexToWorld(indx, indx); + + /* ============= overwrite slice ============*/ + + vtkSmartPointer resliceIdx3 = vtkSmartPointer::New(); + resliceIdx3->SetOverwriteMode(true); + resliceIdx3->SetInputSlice(slice); + mitk::ExtractSliceFilter::Pointer overwriter3 = mitk::ExtractSliceFilter::New(resliceIdx3); + overwriter3->SetInput(workingImage); + overwriter3->SetWorldGeometry(obliquePlane); + overwriter3->SetVtkOutputRequest(true); + overwriter3->Modified(); + overwriter3->Update(); + + + + + /* ============= check ============*/ + areSame = true; + + int x,y,z; + + for ( x = 0; x < VolumeSize; ++x){ + id[0] = x; + for ( y = 0; y < VolumeSize; ++y){ + id[1] = y; + for ( z = 0; z < VolumeSize; ++z){ + id[2] = z; + areSame = refImg->GetPixelValueByIndex(id) == workingImage->GetPixelValueByIndex(id); + if(!areSame) + goto stop3; + } + } + } stop3: - //MITK_INFO << "index: [" << x << ", " << y << ", " << z << "]"; - //MITK_INFO << indx; - MITK_TEST_CONDITION(x==idX && y==z,"overwrited the right index [oblique]"); + //MITK_INFO << "index: [" << x << ", " << y << ", " << z << "]"; + //MITK_INFO << indx; + MITK_TEST_CONDITION(x==idX && y==z,"overwrited the right index [oblique]"); } /*================ #BEGIN test main ================*/ int mitkOverwriteSliceFilterTest(int argc, char* argv[]) { - MITK_TEST_BEGIN("mitkOverwriteSliceFilterTest") + MITK_TEST_BEGIN("mitkOverwriteSliceFilterTest") - + - typedef itk::Image ImageType; + typedef itk::Image ImageType; - typedef itk::ImageRegionConstIterator< ImageType > ImageIterator; + typedef itk::ImageRegionConstIterator< ImageType > ImageIterator; - ImageType::Pointer image = ImageType::New(); + ImageType::Pointer image = ImageType::New(); - ImageType::IndexType start; - start[0] = start[1] = start[2] = 0; + ImageType::IndexType start; + start[0] = start[1] = start[2] = 0; - ImageType::SizeType size; - size[0] = size[1] = size[2] = VolumeSize; + ImageType::SizeType size; + size[0] = size[1] = size[2] = VolumeSize; - ImageType::RegionType imgRegion; - imgRegion.SetSize(size); - imgRegion.SetIndex(start); + ImageType::RegionType imgRegion; + imgRegion.SetSize(size); + imgRegion.SetIndex(start); - image->SetRegions(imgRegion); - image->SetSpacing(1.0); - image->Allocate(); + image->SetRegions(imgRegion); + image->SetSpacing(1.0); + image->Allocate(); - ImageIterator imageIterator( image, image->GetLargestPossibleRegion() ); - imageIterator.GoToBegin(); + ImageIterator imageIterator( image, image->GetLargestPossibleRegion() ); + imageIterator.GoToBegin(); - - unsigned short pixelValue = 0; - - //fill the image with distinct values - while ( !imageIterator.IsAtEnd() ) - { - image->SetPixel(imageIterator.GetIndex(), pixelValue); - ++imageIterator; - ++pixelValue; - } - /* end setup itk image */ - + + unsigned short pixelValue = 0; + + //fill the image with distinct values + while ( !imageIterator.IsAtEnd() ) + { + image->SetPixel(imageIterator.GetIndex(), pixelValue); + ++imageIterator; + ++pixelValue; + } + /* end setup itk image */ + - mitk::Image::Pointer refImage; - CastToMitkImage(image, refImage); - mitk::Image::Pointer workingImg; - CastToMitkImage(image, workingImg); - OverwriteByPointerTest(workingImg, refImage); + mitk::Image::Pointer refImage; + CastToMitkImage(image, refImage); + mitk::Image::Pointer workingImg; + CastToMitkImage(image, workingImg); + OverwriteByPointerTest(workingImg, refImage); - - mitk::Image::Pointer workingImg3; - CastToMitkImage(image, workingImg3); - OverwriteByPointerForObliquePlaneTest(workingImg3, refImage); + + mitk::Image::Pointer workingImg3; + CastToMitkImage(image, workingImg3); + OverwriteByPointerForObliquePlaneTest(workingImg3, refImage); - MITK_TEST_END() + MITK_TEST_END() } diff --git a/Modules/Segmentation/Algorithms/DiffSliceOperation.h b/Modules/Segmentation/Algorithms/DiffSliceOperation.h index 0e005d02f5..f254211c4e 100644 --- a/Modules/Segmentation/Algorithms/DiffSliceOperation.h +++ b/Modules/Segmentation/Algorithms/DiffSliceOperation.h @@ -1,117 +1,117 @@ /*=================================================================== 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. ===================================================================*/ #ifndef mitkDiffSliceOperation_h_Included #define mitkDiffSliceOperation_h_Included #include "SegmentationExports.h" #include "mitkCommon.h" #include //#include "mitkCompressedImageContainer.h" #include #include #include namespace mitk { /** \brief An Operation for applying an edited slice to the volume. \sa DiffSliceOperationApplier The information for the operation is specified by properties: imageVolume the volume where the slice was extracted from. slice the slice to be applied. timestep the timestep in an 4D image. currentWorldGeometry specifies the axis where the slice has to be applied in the volume. - This Operation can be used to realize undo-redo functionality for e.g. segmentation. + This Operation can be used to realize undo-redo functionality for e.g. segmentation purposes. */ class Segmentation_EXPORT DiffSliceOperation : public Operation { public: mitkClassMacro(DiffSliceOperation, OperationActor); //itkNewMacro(DiffSliceOperation); //mitkNewMacro4Param(DiffSliceOperation,mitk::Image,mitk::Image,unsigned int, mitk::Geometry2D); /** \brief Creates an empty instance. Note that it is not valid yet. The properties of the object have to be set. */ DiffSliceOperation(); /** \brief */ DiffSliceOperation( mitk::Image* imageVolume, vtkImageData* slice, AffineGeometryFrame3D* sliceGeometry, unsigned int timestep, AffineGeometryFrame3D* currentWorldGeometry); /** \brief Check if it is a valid operation.*/ bool IsValid(); /** \brief Set the image volume.*/ void SetImage(mitk::Image* image){ this->m_Image = image;} /** \brief Get th image volume.*/ mitk::Image* GetImage(){return this->m_Image;} /** \brief Set thee slice to be applied.*/ void SetImage(vtkImageData* slice){ this->m_Slice = slice;} /** \brief Get the slice that is applied in the operation.*/ vtkImageData* GetSlice(); /** \brief Get timeStep.*/ void SetTimeStep(unsigned int timestep){this->m_TimeStep = timestep;} /** \brief Set timeStep*/ unsigned int GetTimeStep(){return this->m_TimeStep;} /** \brief Set the axis where the slice has to be applied in the volume.*/ void SetSliceGeometry(AffineGeometryFrame3D* sliceGeometry){this->m_SliceGeometry = sliceGeometry;} /** \brief Get the axis where the slice has to be applied in the volume.*/ AffineGeometryFrame3D* GetSliceGeometry(){return this->m_SliceGeometry;} /** \brief Set the axis where the slice has to be applied in the volume.*/ void SetCurrentWorldGeometry(AffineGeometryFrame3D* worldGeometry){this->m_WorldGeometry = worldGeometry;} /** \brief Get the axis where the slice has to be applied in the volume.*/ AffineGeometryFrame3D* GetWorldGeometry(){return this->m_WorldGeometry;} protected: virtual ~DiffSliceOperation(); /** \brief Callback for image observer.*/ void OnImageDeleted(); //CompressedImageContainer::Pointer m_zlibSliceContainer; mitk::Image* m_Image; vtkSmartPointer m_Slice; AffineGeometryFrame3D::Pointer m_SliceGeometry; unsigned int m_TimeStep; AffineGeometryFrame3D::Pointer m_WorldGeometry; bool m_ImageIsValid; unsigned long m_DeleteObserverTag; }; } #endif \ No newline at end of file diff --git a/Modules/Segmentation/Algorithms/mitkVtkImageOverwrite.h b/Modules/Segmentation/Algorithms/mitkVtkImageOverwrite.h index 1a9441762a..c6a5e40913 100644 --- a/Modules/Segmentation/Algorithms/mitkVtkImageOverwrite.h +++ b/Modules/Segmentation/Algorithms/mitkVtkImageOverwrite.h @@ -1,87 +1,88 @@ /*=================================================================== 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. ===================================================================*/ #ifndef mitkVtkImageOverwrite_h_Included #define mitkVtkImageOverwrite_h_Included #include #include "SegmentationExports.h" /** \brief A vtk Filter based on vtkImageReslice with the aditional feature to write a slice into the given input volume. All optimizations for e.g. the plane directions or interpolation are stripped away, the algorithm only interpolates nearest - neighbor and uses the non optimized execute function of vtkImageReslice. + neighbor and uses the non optimized execute function of vtkImageReslice. Note that any interpolation doesn't make sense + for round trip use extract->edit->overwrite, because it is nearly impossible to invert the interolation. There are two use cases for the Filter which are specified by the overwritemode property: 1)Extract slices from a 3D volume. Overwritemode = false In this mode the class can be used like vtkImageReslice. The usual way to do this is: - Set an image volume as input - Set the ResliceAxes via SetResliceAxesDirectionCosines and SetResliceAxesOrigin - Set the the OutputSpacing, OutputOrigin and OutputExtent - Call Update 2)Overwrite a 3D volume at a given slice. Overwritemode = true The handling in this mode is quite similar to the description above with the addition that the InputSlice needs to be specified via SetInputSlice(vtkImageData*). - Set the properties mentioned above (Note that SetInput specifies the volume to write to) - Set the slice to that has to be overwritten in the volume ( SetInputSlice(vtkImageData*) After calling Update() there is no need to retrieve the output as the input volume is modified. \sa vtkImageReslice - (Note that the execute and interpolation function are no members and thus can not be overriden) + (Note that the execute and interpolation functions are no members and thus can not be overriden) */ class Segmentation_EXPORT mitkVtkImageOverwrite : public vtkImageReslice { public: static mitkVtkImageOverwrite *New(); vtkTypeMacro(mitkVtkImageOverwrite, vtkImageReslice); /** \brief Set the mode either to reslice (false) or to overwrite (true). Default: false */ void SetOverwriteMode(bool b); bool IsOverwriteMode(){return m_Overwrite_Mode;} /** \brief Set the slice for overwrite mode. Note: It is recommend not to use this in reslice mode because otherwise the slice will be modified! */ void SetInputSlice(vtkImageData* slice); protected: mitkVtkImageOverwrite(); virtual ~mitkVtkImageOverwrite(); bool m_Overwrite_Mode; /** Overridden from vtkImageReslice. \sa vtkImageReslice::ThreadedRequestData */ virtual void ThreadedRequestData(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), vtkInformationVector *vtkNotUsed(outputVector), vtkImageData ***inData, vtkImageData **outData, int outExt[6], int id); }; #endif //mitkVtkImageOverwrite_h_Included