22 #include <itkFastChamferDistanceImageFilter.h>
23 #include <itkInvertIntensityImageFilter.h>
24 #include <itkIsoContourDistanceImageFilter.h>
25 #include <itkSubtractImageFilter.h>
29 unsigned int lowerSliceIndex,
31 unsigned int upperSliceIndex,
32 unsigned int requestedIndex,
45 float ratio = (float)(requestedIndex - lowerSliceIndex) / (float)(upperSliceIndex - lowerSliceIndex);
47 resultImage, InterpolateIntermediateSlice, 2, upperDistanceImage, lowerDistanceImage, ratio);
52 template <
typename TPixel,
unsigned int VImageDimension>
53 void mitk::ShapeBasedInterpolationAlgorithm::ComputeDistanceMap(
const itk::Image<TPixel, VImageDimension> *binaryImage,
56 typedef itk::Image<TPixel, VImageDimension> DistanceFilterInputImageType;
58 typedef itk::FastChamferDistanceImageFilter<DistanceFilterImageType, DistanceFilterImageType> DistanceFilterType;
59 typedef itk::IsoContourDistanceImageFilter<DistanceFilterInputImageType, DistanceFilterImageType> IsoContourType;
60 typedef itk::InvertIntensityImageFilter<DistanceFilterInputImageType> InvertIntensityImageFilterType;
61 typedef itk::SubtractImageFilter<DistanceFilterImageType, DistanceFilterImageType> SubtractImageFilterType;
71 int maximumDistance = 100;
74 invertFilter->SetInput(binaryImage);
75 invertFilter->SetMaximum(1);
78 isoContourFilter->SetInput(binaryImage);
79 isoContourFilter->SetFarValue(maximumDistance + 1);
80 isoContourFilter->SetLevelSetValue(0.5);
82 isoContourFilterInverted->SetInput(invertFilter->GetOutput());
83 isoContourFilterInverted->SetFarValue(maximumDistance + 1);
84 isoContourFilterInverted->SetLevelSetValue(0.5);
86 distanceFilter->SetInput(isoContourFilter->GetOutput());
87 distanceFilter->SetMaximumDistance(maximumDistance);
89 distanceFilterInverted->SetInput(isoContourFilterInverted->GetOutput());
90 distanceFilterInverted->SetMaximumDistance(maximumDistance);
93 subtractImageFilter->SetInput2(distanceFilter->GetOutput());
94 subtractImageFilter->SetInput1(distanceFilterInverted->GetOutput());
95 subtractImageFilter->Update();
100 template <
typename TPixel,
unsigned int VImageDimension>
101 void mitk::ShapeBasedInterpolationAlgorithm::InterpolateIntermediateSlice(itk::Image<TPixel, VImageDimension> *result,
114 itk::ImageRegionConstIteratorWithIndex<DistanceFilterImageType> lowerIter(lowerITK,
115 lowerITK->GetLargestPossibleRegion());
117 lowerIter.GoToBegin();
119 if (!lowerITK->GetLargestPossibleRegion().IsInside(upperITK->GetLargestPossibleRegion()) ||
120 !lowerITK->GetLargestPossibleRegion().IsInside(result->GetLargestPossibleRegion()))
123 MITK_ERROR <<
"The regions of the slices for the 2D interpolation are not equally sized!";
127 float weight[2] = {1.0f - ratio, ratio};
129 while (!lowerIter.IsAtEnd())
135 (weight[0] * upperPixelVal + weight[1] * lowerPixelVal > 0 ? 0 : 1);
137 result->SetPixel(lowerIter.GetIndex(),
static_cast<TPixel
>(intermediatePixelVal));
itk::SmartPointer< Self > Pointer
#define AccessFixedDimensionByItk_3(mitkImage, itkImageTypeFunction, dimension, arg1, arg2, arg3)
Image::Pointer GrabItkImageMemory(itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.
Image::Pointer Interpolate(Image::ConstPointer lowerSlice, unsigned int lowerSliceIndex, Image::ConstPointer upperSlice, unsigned int upperSliceIndex, unsigned int requestedIndex, unsigned int sliceDimension, Image::Pointer resultImage, unsigned int timeStep, Image::ConstPointer referenceImage) override
::mitk::Image ResultImageType
#define AccessFixedDimensionByItk_1(mitkImage, itkImageTypeFunction, dimension, arg1)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.