| 49 | } |
| 50 | |
| 51 | void mitk::CorrectorAlgorithm::GenerateData() |
| 52 | { |
| 53 | Image::Pointer inputImage = ImageToImageFilter::GetInput(0); |
| 54 | |
| 55 | if (inputImage.IsNull() || inputImage->GetDimension() != 2) |
| 56 | { |
| 57 | itkExceptionMacro("CorrectorAlgorithm needs a 2D image as input."); |
| 58 | } |
| 59 | |
| 60 | if (m_Contour.IsNull()) |
| 61 | { |
| 62 | itkExceptionMacro("CorrectorAlgorithm needs a Contour object as input."); |
| 63 | } |
| 64 | |
| 65 | // copy the input (since m_WorkingImage will be changed later) |
| 66 | m_WorkingImage = inputImage; |
| 67 | |
| 68 | TimeGeometry::Pointer originalGeometry = nullptr; |
| 69 | |
| 70 | if (inputImage->GetTimeGeometry()) |
| 71 | { |
| 72 | originalGeometry = inputImage->GetTimeGeometry()->Clone(); |
| 73 | m_WorkingImage->SetTimeGeometry(originalGeometry); |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | itkExceptionMacro("Original image does not have a 'Time sliced geometry'! Cannot copy."); |
| 78 | } |
| 79 | |
| 80 | Image::Pointer temporarySlice; |
| 81 | |
| 82 | // Convert to DefaultSegmentationDataType (because TobiasHeimannCorrectionAlgorithm relies on that data type) |
| 83 | { |
| 84 | itk::Image<DefaultSegmentationDataType, 2>::Pointer correctPixelTypeImage; |
| 85 | CastToItkImage(m_WorkingImage, correctPixelTypeImage); |
| 86 | assert(correctPixelTypeImage.IsNotNull()); |
| 87 | |
| 88 | // possible bug in CastToItkImage ? |
| 89 | // direction maxtrix is wrong/broken/not working after CastToItkImage, leading to a failed assertion in |
| 90 | // mitk/Core/DataStructures/mitkSlicedGeometry3D.cpp, 479: |
| 91 | // virtual void mitk::SlicedGeometry3D::SetSpacing(const mitk::Vector3D&): Assertion `aSpacing[0]>0 && aSpacing[1]>0 |
| 92 | // && aSpacing[2]>0' failed |
| 93 | // solution here: we overwrite it with an unity matrix |
| 94 | itk::Image<DefaultSegmentationDataType, 2>::DirectionType imageDirection; |
| 95 | |
| 96 | imageDirection.SetIdentity(); |
| 97 | // correctPixelTypeImage->SetDirection(imageDirection); |
| 98 | |
| 99 | temporarySlice = this->GetOutput(); |
| 100 | // temporarySlice = ImportItkImage( correctPixelTypeImage ); |
| 101 | // m_FillColor = 1; |
| 102 | m_EraseColor = 0; |
| 103 | |
| 104 | ImprovedHeimannCorrectionAlgorithm(correctPixelTypeImage); |
| 105 | |
| 106 | // this is suboptimal, needs to be kept synchronous to DefaultSegmentationDataType |
| 107 | if (inputImage->GetChannelDescriptor().GetPixelType().GetComponentType() == itk::IOComponentEnum::USHORT) |
| 108 | { // the cast at the beginning did not copy the data |
nothing calls this directly
no test coverage detected