[Insight-users] trouble using
itkApproximateSignedDistanceMapImageFilter
Alexandra Lauric
alauri02 at cs.tufts.edu
Tue Jan 29 12:16:48 EST 2008
Hi,
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:
*excp {m_Location="void __thiscall
itk::MultiThreader::SingleMethodExecute(void)" m_Description="itk::ERROR:
MultiThreader(02144028): Exception occurred during SingleMethodExecute
c:\itk\insight\code\algorithms\itkIsoContourDistanceImageFilter.txx:330:
itk::ERROR: IsoContourDistanceImageFilter(054C0948): Gradient norm is lower
than pixel precision" m_What="..\..\..\Insight\Code\Common\itkMultiThreade
. *
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.
Thank you,
Alex
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
typedef signed short PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef itk::GDCMImageIO ImageIOType;
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
ImageIOType::Pointer gdcmIO = ImageIOType::New();
NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
namesGenerator->SetInputDirectory( argv[1] );
const ReaderType::FileNamesContainer & filenames =
namesGenerator->GetInputFileNames();
ReaderType::Pointer reader = ReaderType::New();
reader->SetImageIO( gdcmIO );
reader->SetFileNames( filenames );
try
{
reader->Update();
}
catch (itk::ExceptionObject &excp)
{
std::cerr << "Exception thrown while writing the image" << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
//***************************************************************
typedef double InternPixelType;
typedef itk::Image< InternPixelType, 3 > InternImageType;
typedef itk::ConnectedThresholdImageFilter< ImageType, ImageType >
ThreshFilterType;
typedef itk::MinimumMaximumImageCalculator< ImageType>
MinMaxFilterType;
typedef itk::CastImageFilter< ImageType, InternImageType >
CastFilterType;
typedef itk::ApproximateSignedDistanceMapImageFilter< InternImageType,
InternImageType > DistanceFilterType;
MinMaxFilterType::Pointer minMaxFilter = MinMaxFilterType::New();
ThreshFilterType::Pointer threshFilter = ThreshFilterType::New();
DistanceFilterType::Pointer distFilter = DistanceFilterType::New();
CastFilterType::Pointer castFilter = CastFilterType::New();
PixelType maxValue;
PixelType minValue;
if(argc == 4)
minValue = atoi(argv[3]);
else
minValue = 600;
itk::Index<3> seed;
minMaxFilter->SetImage(reader->GetOutput());
minMaxFilter->Compute();
maxValue = minMaxFilter->GetMaximum();
seed = minMaxFilter->GetIndexOfMaximum();
threshFilter->SetInput(reader->GetOutput());
threshFilter->SetUpper( maxValue );
threshFilter->SetLower( minValue );
threshFilter->SetReplaceValue(255);
threshFilter->AddSeed( seed );
threshFilter->Update();
castFilter->SetInput(threshFilter->GetOutput());
castFilter->Update();
distFilter->SetInput(castFilter->GetOutput());
distFilter->SetInsideValue(255);
distFilter->SetOutsideValue(0);
distFilter->Update();
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080129/53064768/attachment.htm
More information about the Insight-users
mailing list