[Insight-users] Signed Danielsson

Einstein, Daniel R daniel.einstein at pnl.gov
Thu Oct 20 12:01:08 EDT 2005


Hello friends,

I am trying to compute the Euclidean distance map on a binary volume and
am getting weird results. 

Data is available at ftp://ftp.pnl.gov/outgoing/SignedDanielsson

See Screenshot.png for a look at what the cross section looks like. This
is a simplification, but basically the volume is a cylinder of that
cross-section. ScreenShot2.png shows the result of the Signed Danielsson
Map - not what I expected. I expected zero to be the border; negative to
be 'outside'; and positive to be 'inside'. Sort of like and image within
an image. Reduced.mha is the header and reduced.raw.zip is the image. It
is a binary image of 1 and 11 - I pass the image as floats to the
itkSignedDanielssonFilter. Am I expecting the wrong thing or doing it
wrong.

Any help would be greatly appreciated.

Dan

See code snippet below.

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++
// ITK Signed Danielsson Distance Map
//
void ThreeDFilters::distanceFilter(float *ddvimage, int xdim, int ydim,
int zdim,
                                      int numiter, QApplication *app)
{
//
//  
//
***********************************************************************
//         Preliminaries to copy the  ddv array into an ITK Image type
*
//
***********************************************************************
//
//              Pass the dimensions and type of ddv array
  typedef float PixelType;
  const unsigned int Dimension = 3;
  typedef itk::Image< PixelType, Dimension > ImageType;
  typedef itk::Image< float, 3 > ImageType;

// image origin
  float ox = 0.0;
  float oy = 0.0;
  float oz = 0.0;
// pixel spacing
  float dx = 1.0;
  float dy = 1.0;
  float dz = 1.0;

  ImageType::Pointer itkimage = ImageType::New();
   ImageType::SizeType size;   size[0] = xdim;   size[1] = ydim;
  size[2] = zdim;
   ImageType::IndexType start;   start[0] = 0;   start[1] = 0;
  start[2] = 0;
   ImageType::RegionType region;   region.SetSize( size );
region.SetIndex( start );   itkimage->SetRegions( region);
   itkimage->Allocate();
   double spacing[3];   spacing[0] = dx;   spacing[1] = dy;
  spacing[2] = dz;   itkimage->SetSpacing( spacing );
   double origin[3];   origin[0] = ox;   origin[1] = oy;
  origin[2] = oz;   itkimage->SetOrigin( origin );
   typedef itk::ImageRegionIterator< ImageType> IteratorType;
IteratorType it( itkimage, region );   it.GoToBegin();   float * data =
ddvimage;   while( ! it.IsAtEnd() )     {     it.Set( *data);     ++it;
++data;     }

// ****************************************************************
//                      End preliminaries                         *
// ****************************************************************
//
//  typedef itk::RescaleIntensityImageFilter< 
//              ImageType, ImageType > preRescaleFilterType;
//  preRescaleFilterType::Pointer prerescaler =
preRescaleFilterType::New();
//  prerescaler->SetOutputMinimum(   0 );
//  prerescaler->SetOutputMaximum( 255 );
//  prerescaler->SetInput( itkimage );
//
//       SIGNED DISTANCE MAP WITH AUTOMATIC RESCALING
  typedef    float    OutputPixelType;
  typedef itk::Image< OutputPixelType, 3 >   OutputImageType;
  typedef itk::SignedDanielssonDistanceMapImageFilter<
                                         ImageType, 
                                         OutputImageType >  FilterType;
  FilterType::Pointer filter = FilterType::New(); 
  filter->SetInput( itkimage );

  typedef itk::RescaleIntensityImageFilter< 
              OutputImageType, OutputImageType > RescaleFilterType;
  RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
  rescaler->SetOutputMinimum(   0L );
  rescaler->SetOutputMaximum( 65535L );
  rescaler->SetInput( filter->GetOutput() );
//
//
// **************************************************************
//                          End Filter                          *
// **************************************************************
//
// **************************************************************
// Begin Conclusion: This writes the image back to the local    *
// buffer and should be written as a generic callable function  *
// **************************************************************
//
  PixelType* pixelData= static_cast<PixelType* >(ddvimage);   const bool
filterWillDeleteTheInputBuffer = false;   const unsigned int
totalNumberOfPixels = xdim*ydim*zdim;
rescaler->GetOutput()->GetPixelContainer()->SetImportPointer(pixelData,
totalNumberOfPixels,filterWillDeleteTheInputBuffer);
rescaler->GetOutput()->Allocate();   rescaler->Update();

// 
//
printf("done ITK Signed Danielsson Distance Map\n");
  if ( pd ) {
    delete pd;
    QApplication::restoreOverrideCursor(); 
  }

}
Daniel R Einstein, PhD
Biological Monitoring and Modeling
Pacific Northwest National Laboratory
P.O. Box 999; MSIN P7-58
Richland, WA 99352
Tel: 509/ 376-2924
Fax: 509/376-9064
daniel.einstein at pnl.gov



Daniel R Einstein, PhD
Biological Monitoring and Modeling
Pacific Northwest National Laboratory
P.O. Box 999; MSIN P7-58
Richland, WA 99352
Tel: 509/ 376-2924
Fax: 509/376-9064
daniel.einstein at pnl.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051020/bbbdd6fd/attachment.htm


More information about the Insight-users mailing list