Hi,<br>I have some trouble using itkApproximateSignedDistanceMapImageFilter on several DICOM datasets, all of size 256x256x229. Basically, I'm thresholding the data to a binary image, using a cast filter from short to double (I've tried float, too) and applying the distance field filter. For some data sets this works fine. On others I get the following error:<br>
<br><i>excp {m_Location="void __thiscall itk::MultiThreader::SingleMethodExecute(void)" m_Description="itk::ERROR: MultiThreader(02144028): Exception occurred during SingleMethodExecute<br>c:\itk\insight\code\algorithms\itkIsoContourDistanceImageFilter.txx:330:<br>
itk::ERROR: IsoContourDistanceImageFilter(054C0948): Gradient norm is lower than pixel precision" m_What="..\..\..\Insight\Code\Common\itkMultiThreade . </i> <br><br>All datasets have the same characteristics. Sometimes, if it doesn't work on the whole dataset, it will work on some subsets, but I couldn't find a pattern. My code is attached below. Any help would be greatly appreciated.<br>
<br>Thank you,<br>Alex<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
typedef signed short PixelType;<br> const unsigned int Dimension = 3;<br><br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>
<br><br> typedef itk::GDCMImageIO ImageIOType;<br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br><br> ImageIOType::Pointer gdcmIO = ImageIOType::New();<br> NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();<br>
<br> namesGenerator->SetInputDirectory( argv[1] );<br><br> const ReaderType::FileNamesContainer & filenames = <br> namesGenerator->GetInputFileNames();<br><br> ReaderType::Pointer reader = ReaderType::New();<br>
<br> reader->SetImageIO( gdcmIO );<br> reader->SetFileNames( filenames );<br><br><br> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject &excp)<br> {<br> std::cerr << "Exception thrown while writing the image" << std::endl;<br>
std::cerr << excp << std::endl;<br> return EXIT_FAILURE;<br> }<br><br><br>//***************************************************************<br><br><br> typedef double InternPixelType;<br><br> typedef itk::Image< InternPixelType, 3 > InternImageType;<br>
typedef itk::ConnectedThresholdImageFilter< ImageType, ImageType > ThreshFilterType;<br> typedef itk::MinimumMaximumImageCalculator< ImageType> MinMaxFilterType;<br> typedef itk::CastImageFilter< ImageType, InternImageType > CastFilterType;<br>
typedef itk::ApproximateSignedDistanceMapImageFilter< InternImageType, InternImageType > DistanceFilterType;<br><br> MinMaxFilterType::Pointer minMaxFilter = MinMaxFilterType::New();<br> ThreshFilterType::Pointer threshFilter = ThreshFilterType::New();<br>
DistanceFilterType::Pointer distFilter = DistanceFilterType::New();<br> CastFilterType::Pointer castFilter = CastFilterType::New();<br><br> PixelType maxValue;<br> PixelType minValue;<br> <br> if(argc == 4)<br>
minValue = atoi(argv[3]);<br> else<br> minValue = 600;<br><br> itk::Index<3> seed;<br><br> minMaxFilter->SetImage(reader->GetOutput());<br> minMaxFilter->Compute();<br> maxValue = minMaxFilter->GetMaximum();<br>
seed = minMaxFilter->GetIndexOfMaximum();<br><br> threshFilter->SetInput(reader->GetOutput());<br> threshFilter->SetUpper( maxValue );<br> threshFilter->SetLower( minValue );<br> threshFilter->SetReplaceValue(255);<br>
threshFilter->AddSeed( seed );<br> threshFilter->Update();<br> <br> castFilter->SetInput(threshFilter->GetOutput());<br> castFilter->Update();<br><br> distFilter->SetInput(castFilter->GetOutput());<br>
distFilter->SetInsideValue(255);<br> distFilter->SetOutsideValue(0);<br> distFilter->Update();<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>