[Insight-users] discrete gaussian filter causes exception
Toon Huysmans
denhuys at hotmail.com
Thu May 27 11:53:09 EDT 2004
Hi Lydia,
I solved the problem, I am not shure what caused it but removing line 318
fom THCochleaSegmentationLevelSet.cpp
fixed it:
planeSet->SetInput(itkExporter->GetOutput());
The line was executed every time I changed the input of castFilter3.
castFilter3 is the filter connected to itkExporter for
visualizing the different images in my pipeline.
The reason why line 318 was there is that this way the planeset recalculates
its lookuptable adjusted to the range of its
input. Deleting that line stopped the exceptions.
Thank you,
Toon.
----- Original Message -----
From: "Lydia Ng" <lng at insightful.com>
To: "Toon Huysmans" <denhuys at hotmail.com>; <insight-users at itk.org>
Sent: Thursday, May 27, 2004 3:54 PM
Subject: RE: [Insight-users] discrete gaussian filter causes exception
Toon,
It's hard to say what's going on remotely - here are some suggestions which
might help debug the problem.
[1] You error seem to be an "access violation" within the CastImageFilter -
do you know if it is the CastImageFilter before or after the
DiscreteGaussian?
[2] Are you able via the debugger to determine what the issues are?
For example, when you reach the line you marked (/******HERE******/), what
are the regions (LargestPossible, Buffered, Requested) of the input and the
output? What is the offset of the iterators when the access violation
occurs?
[3] Since you say that the code works fine with the recursive gaussian
filter, I am wondering if this is a kernel size issue.
What is the size of you input data? Can you via the debugger get the size of
the kernel after line 167 of itkDiscreteGaussianImageFilter.txx
oper[i].CreateDirectional();
An experiment you could try is to either reduce the MaximumKernelWidth or
increase the MaximumError to try to reduce the kernel size.
There could potentially be some issue if the kernel size greater than half
the image in any dimension.
- Lydia
> -----Original Message-----
> From: Toon Huysmans [mailto:denhuys at hotmail.com]
> Sent: Thursday, May 27, 2004 3:18 AM
> To: insight-users at itk.org
> Subject: [Insight-users] discrete gaussian filter causes exception
>
> Hi,
>
> I have got a strange error. I simply want to blur a 3D image. When I
> do
> this using the recursive gaussian filter, there are no errors, but the
> smoothing is only in one dimension.
> So now I use the discrete gaussian filter, and I didn`t change my code
> except for the setting of the parameter Variance. But the filter throws
> an
> exception in itkUnaryFunctorImageFilter.txx at line 147.
>
> extract from itkUnaryFunctorImageFilter.txx:
> --------------------------------------------------------------------------
> --
> --------------------------------------------------------------------------
> --
> ------------
> /**
> * ThreadedGenerateData Performs the pixel-wise addition
> */
> template <class TInputImage, class TOutputImage, class TFunction >
> void
> UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction>::ThreadedGener
> at
> eData( const OutputImageRegionType &outputRegionForThread,int threadId)
> {
> InputImagePointer inputPtr = this->GetInput();
> OutputImagePointer outputPtr = this->GetOutput(0);
> // Define the portion of the input to walk for this thread, using
> // the CallCopyOutputRegionToInputRegion method allows for the input
> // and output images to be different dimensions
> InputImageRegionType inputRegionForThread;
> this->CallCopyOutputRegionToInputRegion(inputRegionForThread,
> outputRegionForThread);
> // Define the iterators
> ImageRegionConstIterator<TInputImage> inputIt(inputPtr,
> inputRegionForThread);
> ImageRegionIterator<TOutputImage> outputIt(outputPtr,
> outputRegionForThread);
> ProgressReporter progress(this, threadId,
> outputRegionForThread.GetNumberOfPixels());
> inputIt.GoToBegin();
> outputIt.GoToBegin();
> while( !inputIt.IsAtEnd() )
> {
> outputIt.Set( m_Functor( inputIt.Get() ) );
> (/******HERE******/)
> ++inputIt;
> ++outputIt;
> progress.CompletedPixel(); // potential exception thrown here
> }
> }
> --------------------------------------------------------------------------
> --
> --------------------------------------------------------------------------
> --
> ------------
> The Exception:
>
> Unhandled exception at 0x0042a848 in
> THCochleaSegmentationLevelSet.exe:
> 0xC0000005: Access violation reading location 0x0f171000.
>
> The callstack on exception is:
>
> --------------------------------------------------------------------------
> --
> --------------------------------------------------------------------------
> --
> ------------
>
> THCochleaSegmentationLevelSet.exe!itk::UnaryFunctorImageFilter<itk::Image<
> fl
> oat,3>,itk::Image<unsigned char,3>,itk::Functor::Cast<float,unsigned char>
> >::ThreadedGenerateData(const itk::ImageRegion<3> &
> outputRegionForThread={...}, int threadId=1) Line 147 + 0x4 C++
>
> THCochleaSegmentationLevelSet.exe!itk::ImageSource<itk::Image<unsigned
> char,3> >::ThreaderCallback(void * arg=0x04f283d8) Line 281 C++
>
> msvcr71.dll!_threadstartex(void * ptd=0x04f62a78) Line 241 + 0x6 C
>
> kernel32.dll!77e7d33b()
>
> THCochleaSegmentationLevelSet.exe!itk::Object::~Object() Line 456 +
> 0x12
> C++
> --------------------------------------------------------------------------
> --
> --------------------------------------------------------------------------
> --
> ------------
>
> I have attached my code, the gaussian filter is named blur in my code.
> It seems the code crashes when doing itkExporter->Update(). The pipeline
> on
> that moment is:
>
> ImageFileReader<ImageType>
> CastImageFilter< ImageType, RealImageType >
> DiscreteGaussianImageFilter<RealImageType,RealImageType>
> BinaryThresholdImageFilter<RealImageType,RealImageType>
> CastImageFilter< RealImageType, ImageType >
> ImageToVTKImageFilter<ImageType>
> vtkOrthogonalImagePlaneSet
>
> I know this probably is a fuzzy post but the reason I post this, is that
> by
> replacing a simple filter I get an Exception, so that it could be a bug in
> ITK.
>
> Thanks,
>
>
> Toon.
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list