Commit dd874344 authored by seryc's avatar seryc
Browse files

UPDATE: Try to resolve some memory leak.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@2122 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 6c6e0dc3
...@@ -123,7 +123,7 @@ void MorphologicalOperators::process(ImageComponent * comp) { ...@@ -123,7 +123,7 @@ void MorphologicalOperators::process(ImageComponent * comp) {
// ITK filter implementation // ITK filter implementation
template <class InputPixelType, class OutputPixelType, const int dim> template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::itkProcess(vtkSmartPointer<vtkImageData> img) { vtkSmartPointer<vtkImageData> MorphologicalOperators::itkProcess(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> result; vtkSmartPointer<vtkImageData> result = NULL;
switch (this->getMorphoType()) { switch (this->getMorphoType()) {
...@@ -198,16 +198,16 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma ...@@ -198,16 +198,16 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma
typedef itk::VTKImageToImageFilter<InputImageType> vtkToItkFilterType; typedef itk::VTKImageToImageFilter<InputImageType> vtkToItkFilterType;
typename vtkToItkFilterType::Pointer vtkToItkFilter = vtkToItkFilterType::New(); typename vtkToItkFilterType::Pointer vtkToItkFilter = vtkToItkFilterType::New();
// In the same way, once the image is filtered, we need to convert it again to
// VTK format to give it to CamiTK.
typedef itk::ImageToVTKImageFilter<OutputImageType> itkToVtkFilterType;
typename itkToVtkFilterType::Pointer itkToVtkFilter = itkToVtkFilterType::New();
// Declare and create your own private ITK filter here... // Declare and create your own private ITK filter here...
typedef itk::BinaryBallStructuringElement<InputPixelType, dim> StructuringElementType; typedef itk::BinaryBallStructuringElement<InputPixelType, dim> StructuringElementType;
typedef itk::BinaryErodeImageFilter <InputImageType, OutputImageType, StructuringElementType> FilterType; typedef itk::BinaryErodeImageFilter <InputImageType, OutputImageType, StructuringElementType> FilterType;
typename FilterType::Pointer filter = FilterType::New(); typename FilterType::Pointer filter = FilterType::New();
// In the same way, once the image is filtered, we need to convert it again to
// VTK format to give it to CamiTK.
typedef itk::ImageToVTKImageFilter<OutputImageType> itkToVtkFilterType;
typename itkToVtkFilterType::Pointer itkToVtkFilter = itkToVtkFilterType::New();
// To update CamiTK progress bar while filtering, add an ITK observer to the filters. // To update CamiTK progress bar while filtering, add an ITK observer to the filters.
ItkProgressObserver::Pointer observer = ItkProgressObserver::New(); ItkProgressObserver::Pointer observer = ItkProgressObserver::New();
// ITK observers generally give values between 0 and 1, and CamiTK progress bar // ITK observers generally give values between 0 and 1, and CamiTK progress bar
...@@ -292,6 +292,8 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSm ...@@ -292,6 +292,8 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSm
structuringElement.CreateStructuringElement(); structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement); filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput()); itkToVtkFilter->SetInput(filter->GetOutput());
...@@ -362,10 +364,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSma ...@@ -362,10 +364,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSma
dilationFilter->SetInput(vtkToItkFilter->GetOutput()); dilationFilter->SetInput(vtkToItkFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation ); dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement); dilationFilter->SetKernel(structuringElement);
dilationFilter->Update();
erosionFilter->SetInput(dilationFilter->GetOutput()); erosionFilter->SetInput(dilationFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion ); erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement); erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(erosionFilter->GetOutput()); itkToVtkFilter->SetInput(erosionFilter->GetOutput());
...@@ -441,10 +445,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSma ...@@ -441,10 +445,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSma
erosionFilter->SetInput(vtkToItkFilter->GetOutput()); erosionFilter->SetInput(vtkToItkFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion ); erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement); erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
dilationFilter->SetInput(erosionFilter->GetOutput()); dilationFilter->SetInput(erosionFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation ); dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement); dilationFilter->SetKernel(structuringElement);
dilatationFilter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(dilationFilter->GetOutput()); itkToVtkFilter->SetInput(dilationFilter->GetOutput());
...@@ -514,6 +520,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtk ...@@ -514,6 +520,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtk
structuringElement.SetRadius( structuringElementSize ); structuringElement.SetRadius( structuringElementSize );
structuringElement.CreateStructuringElement(); structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement); filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput()); itkToVtkFilter->SetInput(filter->GetOutput());
...@@ -580,6 +587,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vt ...@@ -580,6 +587,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vt
structuringElement.SetRadius( structuringElementSize ); structuringElement.SetRadius( structuringElementSize );
structuringElement.CreateStructuringElement(); structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement); filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput()); itkToVtkFilter->SetInput(filter->GetOutput());
...@@ -650,10 +658,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtk ...@@ -650,10 +658,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtk
dilationFilter->SetInput(vtkToItkFilter->GetOutput()); dilationFilter->SetInput(vtkToItkFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation ); dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement); dilationFilter->SetKernel(structuringElement);
dilationFilter->Update();
erosionFilter->SetInput(dilationFilter->GetOutput()); erosionFilter->SetInput(dilationFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion ); erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement); erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(erosionFilter->GetOutput()); itkToVtkFilter->SetInput(erosionFilter->GetOutput());
...@@ -727,10 +737,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelOpeningFilter(vtk ...@@ -727,10 +737,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelOpeningFilter(vtk
erosionFilter->SetInput(vtkToItkFilter->GetOutput()); erosionFilter->SetInput(vtkToItkFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion ); erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement); erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
dilationFilter->SetInput(erosionFilter->GetOutput()); dilationFilter->SetInput(erosionFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation ); dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement); dilationFilter->SetKernel(structuringElement);
dilatationFilter->Update();
// From ITK to VTK // From ITK to VTK
itkToVtkFilter->SetInput(dilationFilter->GetOutput()); itkToVtkFilter->SetInput(dilationFilter->GetOutput());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment