Discussion:
[ITK-users] Segfault after SliceBySliceImageFilter
Jonas Teuwen
2017-08-03 22:48:01 UTC
Permalink
Hi all,

I wish to apply a filter slice by slice, for which I use
SliceBySliceImageFilter (after the appropriate definitions):

"""
typedef itk::LaplacianSharpeningImageFilter <ImageType3D,
FloatImageType3D> LaplacianSharpeningImageFilterType;
LaplacianSharpeningImageFilterType::Pointer
LaplacianSharpeningImageFilter = LaplacianSharpeningImageFilterType::New();
LaplacianSharpeningImageFilter->SetInput(reader->GetOutput());
LaplacianSharpeningImageFilter->Update();

typedef itk::FlatStructuringElement<2> StructuringElementType;
StructuringElementType::RadiusType AnnulusRadius;
AnnulusRadius.Fill(10);
StructuringElementType StructuringElement =
StructuringElementType::Annulus(AnnulusRadius, Thickness, false, false);

typedef itk::SliceBySliceImageFilter<FloatImageType3D, FloatImageType3D>
SliceFilterType;
SliceFilterType::Pointer SliceFilter = SliceFilterType::New();

typedef
itk::GrayscaleDilateImageFilter<SliceFilterType::InternalInputImageType,

SliceFilterType::InternalOutputImageType, StructuringElementType>
GrayscaleDilateImageFilterType;
GrayscaleDilateImageFilterType::Pointer GrayscaleDilateImageFilter =
GrayscaleDilateImageFilterType::New();
GrayscaleDilateImageFilter->SetKernel(StructuringElement);

SliceFilter->SetInput(LaplacianSharpeningImageFilter->GetOutput());
SliceFilter->SetFilter(GrayscaleDilateImageFilter);
"""
If I write the output of SliceFilter to a file, I get what I expact, but I
do want to compute the minimum between the result and the sharpened image:

typedef itk::MinimumImageFilter<FloatImageType3D, FloatImageType3D,
FloatImageType3D> MinimumImageFilterType;
typename MinimumImageFilterType::Pointer MinimumImageFilter;
MinimumImageFilter->SetInput(0, SliceFilter->GetOutput());
MinimumImageFilter->SetInput(1,
LaplacianSharpeningImageFilter->GetOutput());

But that immediately segfaults, even before the output is written to disk.
Whichever order, gdb tells me the program crashes at any ->SetInput in the
MinimumImageFilter.
If I on the other hand input a 2D image, and I do not use the
SliceBySliceImageFilter, the program seems to work as expected.

Are there any debugging steps which I could try to find the flaw?

Best,
Jonas
Richard Beare
2017-08-04 00:05:27 UTC
Permalink
You haven't created the MinimumImageFilter:

typename MinimumImageFilterType::Pointer MinimumImageFilter =
MinimumImageFilterType::New()
Post by Jonas Teuwen
Hi all,
I wish to apply a filter slice by slice, for which I use
"""
typedef itk::LaplacianSharpeningImageFilter <ImageType3D,
FloatImageType3D> LaplacianSharpeningImageFilterType;
LaplacianSharpeningImageFilterType::Pointer
LaplacianSharpeningImageFilter = LaplacianSharpeningImageFilter
Type::New();
LaplacianSharpeningImageFilter->SetInput(reader->GetOutput());
LaplacianSharpeningImageFilter->Update();
typedef itk::FlatStructuringElement<2> StructuringElementType;
StructuringElementType::RadiusType AnnulusRadius;
AnnulusRadius.Fill(10);
StructuringElementType StructuringElement = StructuringElementType::Annulus(AnnulusRadius,
Thickness, false, false);
typedef itk::SliceBySliceImageFilter<FloatImageType3D,
FloatImageType3D> SliceFilterType;
SliceFilterType::Pointer SliceFilter = SliceFilterType::New();
InternalInputImageType,
SliceFilterType::InternalOutputImageType,
StructuringElementType> GrayscaleDilateImageFilterType;
GrayscaleDilateImageFilterType::Pointer GrayscaleDilateImageFilter =
GrayscaleDilateImageFilterType::New();
GrayscaleDilateImageFilter->SetKernel(StructuringElement);
SliceFilter->SetInput(LaplacianSharpeningImageFilter->GetOutput());
SliceFilter->SetFilter(GrayscaleDilateImageFilter);
"""
If I write the output of SliceFilter to a file, I get what I expact, but I
typedef itk::MinimumImageFilter<FloatImageType3D, FloatImageType3D,
FloatImageType3D> MinimumImageFilterType;
typename MinimumImageFilterType::Pointer MinimumImageFilter;
MinimumImageFilter->SetInput(0, SliceFilter->GetOutput());
MinimumImageFilter->SetInput(1, LaplacianSharpeningImageFilter
->GetOutput());
But that immediately segfaults, even before the output is written to disk.
Whichever order, gdb tells me the program crashes at any ->SetInput in the
MinimumImageFilter.
If I on the other hand input a 2D image, and I do not use the
SliceBySliceImageFilter, the program seems to work as expected.
Are there any debugging steps which I could try to find the flaw?
Best,
Jonas
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
Loading...