[ITK] ThresholdImageFilter on VectorImage
David Froger
david.froger.ml at mailoo.org
Sun Mar 1 11:11:18 EST 2015
Hi,
Modifying the example:
http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/NthElementImageAdaptor
like this, to apply ThresholdImageFilter instead of BinomialBlurImageFilter
on a VectorImage:
@@ -2,6 +2,7 @@
#include "itkImageRegionIterator.h"
#include "itkNthElementImageAdaptor.h"
#include "itkBinomialBlurImageFilter.h"
+#include <itkThresholdImageFilter.h>
typedef itk::Image<itk::CovariantVector< float, 3>, 2> VectorImageType;
@@ -19,11 +20,13 @@
adaptor->SelectNthElement(0);
adaptor->SetImage(image);
-
- typedef itk::BinomialBlurImageFilter<ImageAdaptorType, itk::Image<float,2> > BlurFilterType;
- BlurFilterType::Pointer blurFilter = BlurFilterType::New();
- blurFilter->SetInput(adaptor);
- blurFilter->Update();
+
+ typedef itk::ThresholdImageFilter<ImageAdaptorType> ThresholderType;
+ typename ThresholderType::Pointer thresholder = ThresholderType::New();
+ thresholder->SetInput(adaptor);
+ thresholder->ThresholdAbove(255);
+ thresholder->SetOutsideValue(255);
+ thresholder->Update();
yield to the segmentation fault:
(gdb) run
Starting program: (...)/ProcessingNthImageElement
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff67a8700 (LWP 7751)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff67a8700 (LWP 7751)]
0x00000000004299f0 in itk::NthElementPixelAccessor<float, itk::CovariantVector<float, 3u> >::Get (this=0x7ffff67a7d1c, input=...)
at (...)/include/ITK-4.8/itkNthElementPixelAccessor.h:71
71 { return static_cast<ExternalType>( DefaultConvertPixelTraits<InternalType>::GetNthComponent( m_ElementNumber, input ) ); }
(gdb) bt
#0 0x00000000004299f0 in itk::NthElementPixelAccessor<float, itk::CovariantVector<float, 3u> >::Get (this=0x7ffff67a7d1c, input=...) at (...)/include/ITK-4.8/itkNthElementPixelAccessor.h:71
#1 0x0000000000428b37 in itk::DefaultPixelAccessorFunctor<itk::ImageAdaptor<itk::Image<itk::CovariantVector<float, 3u>, 2u>, itk::NthElementPixelAccessor<float, itk::CovariantVector<float, 3u> > > >::Get (this=0x7ffff67a7d1c, input=...) at (...)/include/ITK-4.8/itkDefaultPixelAccessorFunctor.h:105
#2 0x0000000000427223 in itk::ImageConstIterator<itk::NthElementImageAdaptor<itk::Image<itk::CovariantVector<float, 3u>, 2u>, float> >::Get (this=0x7ffff67a7cc0) at (...)/include/ITK-4.8/itkImageConstIterator.h:325
#3 0x000000000042224e in itk::ThresholdImageFilter<itk::NthElementImageAdaptor<itk::Image<itk::CovariantVector<float, 3u>, 2u>, float> >::ThreadedGenerateData (this=0x63a6b0, outputRegionForThread=..., threadId=1) at (...)/include/ITK-4.8/itkThresholdImageFilter.hxx:165
#4 0x0000000000426d87 in itk::ImageSource<itk::NthElementImageAdaptor<itk::Image<itk::CovariantVector<float, 3u>, 2u>, float> >::ThreaderCallback (arg=0x63a900) at (...)/include/ITK-4.8/itkImageSource.hxx:307
#5 0x00007ffff7454017 in ?? () from (...)/lib/libITKCommon-4.8.so.1
#6 0x0000003393607e9a in start_thread (arg=0x7ffff67a8700) at pthread_create.c:308
#7 0x0000003392ef43fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#8 0x0000000000000000 in ?? ()
Is there any way to apply ThresholdImageFilter on a VectorImage?
Thanks,
David
More information about the Community
mailing list