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 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) {
// ITK filter implementation
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::itkProcess(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> result;
vtkSmartPointer<vtkImageData> result = NULL;
switch (this->getMorphoType()) {
......@@ -198,16 +198,16 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryErosionFilter(vtkSma
typedef itk::VTKImageToImageFilter<InputImageType> vtkToItkFilterType;
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...
typedef itk::BinaryBallStructuringElement<InputPixelType, dim> StructuringElementType;
typedef itk::BinaryErodeImageFilter <InputImageType, OutputImageType, StructuringElementType> FilterType;
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.
ItkProgressObserver::Pointer observer = ItkProgressObserver::New();
// ITK observers generally give values between 0 and 1, and CamiTK progress bar
......@@ -292,6 +292,8 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryDilationFilter(vtkSm
structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput());
......@@ -362,10 +364,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryClosureFilter(vtkSma
dilationFilter->SetInput(vtkToItkFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement);
dilationFilter->Update();
erosionFilter->SetInput(dilationFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(erosionFilter->GetOutput());
......@@ -441,10 +445,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::binaryOpeningFilter(vtkSma
erosionFilter->SetInput(vtkToItkFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
dilationFilter->SetInput(erosionFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement);
dilatationFilter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(dilationFilter->GetOutput());
......@@ -514,6 +520,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelErosionFilter(vtk
structuringElement.SetRadius( structuringElementSize );
structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput());
......@@ -580,6 +587,7 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelDilationFilter(vt
structuringElement.SetRadius( structuringElementSize );
structuringElement.CreateStructuringElement();
filter->SetKernel(structuringElement);
filter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(filter->GetOutput());
......@@ -650,10 +658,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelClosureFilter(vtk
dilationFilter->SetInput(vtkToItkFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement);
dilationFilter->Update();
erosionFilter->SetInput(dilationFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(erosionFilter->GetOutput());
......@@ -727,10 +737,12 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::greyLevelOpeningFilter(vtk
erosionFilter->SetInput(vtkToItkFilter->GetOutput());
erosionFilter->AddObserver( itk::ProgressEvent(), observerErosion );
erosionFilter->SetKernel(structuringElement);
erosionFilter->Update();
dilationFilter->SetInput(erosionFilter->GetOutput());
dilationFilter->AddObserver ( itk::ProgressEvent(), observerDilation );
dilationFilter->SetKernel(structuringElement);
dilatationFilter->Update();
// From ITK to VTK
itkToVtkFilter->SetInput(dilationFilter->GetOutput());
......
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