Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <mitkManualSegmentationToSurfaceFilter.h>
00019
00020 #include <vtkSmartPointer.h>
00021
00022 #include "mitkProgressBar.h"
00023
00024 mitk::ManualSegmentationToSurfaceFilter::ManualSegmentationToSurfaceFilter()
00025 {
00026 m_MedianFilter3D = false;
00027 m_MedianKernelSizeX = 3;
00028 m_MedianKernelSizeY = 3;
00029 m_MedianKernelSizeZ = 3;
00030 m_UseGaussianImageSmooth = false;
00031 m_GaussianStandardDeviation = 1.5;
00032 m_Interpolation = false;
00033 m_InterpolationX = 1.0f;
00034 m_InterpolationY = 1.0f;
00035 m_InterpolationZ = 1.0f;
00036 };
00037
00038
00039 mitk::ManualSegmentationToSurfaceFilter::~ManualSegmentationToSurfaceFilter(){};
00040
00041 void mitk::ManualSegmentationToSurfaceFilter::GenerateData()
00042 {
00043 mitk::Surface *surface = this->GetOutput();
00044 mitk::Image * image = (mitk::Image*)GetInput();
00045 mitk::Image::RegionType outputRegion = image->GetRequestedRegion();
00046
00047 int tstart=outputRegion.GetIndex(3);
00048 int tmax=tstart+outputRegion.GetSize(3);
00049
00050 ScalarType thresholdExpanded = this->m_Threshold;
00051
00052 if ((tmax-tstart) > 0)
00053 {
00054 ProgressBar::GetInstance()->AddStepsToDo( 7 * (tmax - tstart) );
00055 }
00056
00057 for( int t=tstart; t<tmax; t++ )
00058 {
00059
00060 vtkSmartPointer<vtkImageData> vtkimage = image->GetVtkImageData(t);
00061
00062
00063 MITK_INFO << (m_MedianFilter3D ? "Applying median..." : "No median filtering");
00064 if(m_MedianFilter3D)
00065 {
00066 vtkImageMedian3D *median = vtkImageMedian3D::New();
00067 median->SetInput(vtkimage);
00068 median->SetKernelSize(m_MedianKernelSizeX,m_MedianKernelSizeY,m_MedianKernelSizeZ);
00069 median->ReleaseDataFlagOn();
00070 median->UpdateInformation();
00071 median->Update();
00072 vtkimage = median->GetOutput();
00073 median->Delete();
00074 }
00075 ProgressBar::GetInstance()->Progress();
00076
00077
00078 MITK_INFO << (m_Interpolation ? "Resampling..." : "No resampling");
00079 if(m_Interpolation)
00080 {
00081 vtkImageResample * imageresample = vtkImageResample::New();
00082 imageresample->SetInput(vtkimage);
00083
00084
00085 imageresample->SetAxisOutputSpacing(0, m_InterpolationX);
00086 imageresample->SetAxisOutputSpacing(1, m_InterpolationY);
00087 imageresample->SetAxisOutputSpacing(2, m_InterpolationZ);
00088 imageresample->UpdateInformation();
00089 imageresample->Update();
00090 vtkimage=imageresample->GetOutput();
00091 imageresample->Delete();
00092 }
00093 ProgressBar::GetInstance()->Progress();
00094
00095 MITK_INFO << (m_UseGaussianImageSmooth ? "Applying gaussian smoothing..." : "No gaussian smoothing");
00096 if(m_UseGaussianImageSmooth)
00097 {
00098 vtkImageThreshold* vtkimagethreshold = vtkImageThreshold::New();
00099 vtkimagethreshold->SetInput(vtkimage);
00100 vtkimagethreshold->SetInValue( 100 );
00101 vtkimagethreshold->SetOutValue( 0 );
00102 vtkimagethreshold->ThresholdByUpper( this->m_Threshold );
00103 thresholdExpanded = 49;
00104
00105 vtkimagethreshold->SetOutputScalarTypeToUnsignedChar();
00106 vtkimagethreshold->ReleaseDataFlagOn();
00107
00108 vtkImageGaussianSmooth *gaussian = vtkImageGaussianSmooth::New();
00109 gaussian->SetInput(vtkimagethreshold->GetOutput());
00110 gaussian->SetDimensionality(3);
00111 gaussian->SetRadiusFactor(0.49);
00112 gaussian->SetStandardDeviation( m_GaussianStandardDeviation );
00113 gaussian->ReleaseDataFlagOn();
00114 gaussian->UpdateInformation();
00115 gaussian->Update();
00116 vtkimage = gaussian->GetOutput();
00117 gaussian->Delete();
00118 vtkimagethreshold->Delete();
00119 }
00120 ProgressBar::GetInstance()->Progress();
00121
00122
00123 CreateSurface(t, vtkimage, surface, thresholdExpanded);
00124 ProgressBar::GetInstance()->Progress();
00125 }
00126 };
00127
00128
00129 void mitk::ManualSegmentationToSurfaceFilter::SetMedianKernelSize(int x, int y, int z)
00130 {
00131 m_MedianKernelSizeX = x;
00132 m_MedianKernelSizeY = y;
00133 m_MedianKernelSizeZ = z;
00134 }
00135
00136 void mitk::ManualSegmentationToSurfaceFilter::SetInterpolation(vtkDouble x, vtkDouble y, vtkDouble z)
00137 {
00138 m_InterpolationX = x;
00139 m_InterpolationY = y;
00140 m_InterpolationZ = z;
00141 }
00142