MCPcopy Create free account
hub / github.com/MITK/MITK / ITKCrop3DImage

Method ITKCrop3DImage

Modules/AlgorithmsExt/src/mitkAutoCropImageFilter.cpp:36–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35template <typename TPixel, unsigned int VImageDimension>
36void mitk::AutoCropImageFilter::ITKCrop3DImage(itk::Image<TPixel, VImageDimension> *inputItkImage,
37 unsigned int timestep)
38{
39 if (inputItkImage == nullptr)
40 {
41 mitk::StatusBar::GetInstance()->DisplayErrorText(
42 "An internal error occurred. Can't convert Image. Please report to bugs@mitk.org");
43 MITK_ERROR << "image is nullptr...returning" << std::endl;
44 return;
45 }
46
47 typedef itk::Image<TPixel, VImageDimension> InternalImageType;
48 typedef typename InternalImageType::Pointer InternalImagePointer;
49
50 typedef itk::RegionOfInterestImageFilter<InternalImageType, InternalImageType> ROIFilterType;
51 typedef typename itk::RegionOfInterestImageFilter<InternalImageType, InternalImageType>::Pointer ROIFilterPointer;
52
53 InternalImagePointer outputItk = InternalImageType::New();
54
55 ROIFilterPointer roiFilter = ROIFilterType::New();
56 roiFilter->SetInput(0, inputItkImage);
57 roiFilter->SetRegionOfInterest(this->GetCroppingRegion());
58 roiFilter->Update();
59 outputItk = roiFilter->GetOutput();
60 outputItk->DisconnectPipeline();
61
62 mitk::Image::Pointer newMitkImage = mitk::Image::New();
63 mitk::CastToMitkImage(outputItk, newMitkImage);
64 MITK_INFO << "Crop-Output dimension: " << (newMitkImage->GetDimension() == 3)
65 << " Filter-Output dimension: " << this->GetOutput()->GetDimension() << " Timestep: " << timestep;
66
67 mitk::ImageReadAccessor newMitkImgAcc(newMitkImage);
68 this->GetOutput()->SetVolume(newMitkImgAcc.GetData(), timestep);
69}
70
71void mitk::AutoCropImageFilter::GenerateOutputInformation()
72{

Callers

nothing calls this directly

Calls 10

CastToMitkImageFunction · 0.85
SetRegionOfInterestMethod · 0.80
SetVolumeMethod · 0.80
NewFunction · 0.50
DisplayErrorTextMethod · 0.45
SetInputMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45
GetDimensionMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected