Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 6c6e0dc3 authored by seryc's avatar seryc
Browse files

UPDATE: Try to resolve some memory leak.

Some smartpointers were allocated in a wrong way. 
There are still problems (but less) on Standard Gaussian Filter. I try to solve it later

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@2121 ec899d31-69d1-42ba-9299-647d76f65fb3
parent de1c43ec
......@@ -187,7 +187,7 @@ template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -226,6 +226,8 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma
structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput());
......@@ -235,7 +237,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -243,6 +245,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma
filteredImage->Update();
observer->Reset();
observer = NULL;
return filteredImage;
......@@ -251,7 +254,6 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -299,7 +301,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSm
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -307,6 +309,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSm
filteredImage->Update();
observer->Reset();
observer = NULL;
return filteredImage;
......@@ -315,7 +318,6 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSm
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage = NULL;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -374,7 +376,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSma
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -384,6 +386,9 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSma
observerErosion->Reset();
observerDilation->Reset();
observerDilation = NULL;
observerErosion = NULL;
return filteredImage;
}
......@@ -391,7 +396,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSma
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -450,7 +455,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSma
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -460,6 +465,9 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSma
observerErosion->Reset();
observerDilation->Reset();
observerErosion = NULL;
observerDilation = NULL;
return filteredImage;
}
......@@ -468,7 +476,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSma
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -516,7 +524,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtk
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -524,6 +532,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtk
filteredImage->Update();
observer->Reset();
observer = NULL;
return filteredImage;
......@@ -533,7 +542,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtk
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -581,7 +590,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vt
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -589,6 +598,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vt
filteredImage->Update();
observer->Reset();
observer = NULL;
return filteredImage;
......@@ -596,7 +606,6 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vt
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage = NULL;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -655,7 +664,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtk
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -664,6 +673,8 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtk
observerErosion->Reset();
observerDilation->Reset();
observerDilation = NULL;
observerErosion = NULL;
return filteredImage;
......@@ -672,7 +683,6 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtk
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelOpeningFilter(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> filteredImage = NULL;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
......@@ -731,7 +741,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelOpeningFilter(vtk
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
filteredImage = vtkImageData::New();
vtkSmartPointer<vtkImageData> filteredImage = vtkSmartPointer<vtkImageData>::New();
int extent[6];
resultImage->GetExtent(extent);
filteredImage->SetExtent(extent);
......@@ -740,6 +750,8 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelOpeningFilter(vtk
observerErosion->Reset();
observerDilation->Reset();
observerDilation = NULL;
observerErosion = NULL;
return filteredImage;
......
Markdown is supported
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