<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7232.77">
<TITLE>Signed Danielsson</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<BR>
<P><FONT SIZE=2 FACE="Arial">Hello friends,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I am trying to compute the Euclidean distance map on a binary volume and am getting weird results. </FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Data is available at </FONT><A HREF="ftp://ftp.pnl.gov/outgoing/SignedDanielsson"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">ftp://ftp.pnl.gov/outgoing/SignedDanielsson</FONT></U></A>
</P>
<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Any help would be greatly appreciated.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Dan</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">See code snippet below.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</FONT>
<BR><FONT SIZE=2 FACE="Arial">// ITK Signed Danielsson Distance Map</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">void ThreeDFilters::distanceFilter(float *ddvimage, int xdim, int ydim, int zdim,</FONT>
<BR><FONT SIZE=2 FACE="Arial"> int numiter, QApplication *app)</FONT>
<BR><FONT SIZE=2 FACE="Arial">{</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// </FONT>
<BR><FONT SIZE=2 FACE="Arial">// ***********************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// Preliminaries to copy the ddv array into an ITK Image type *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// ***********************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// Pass the dimensions and type of ddv array</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef float PixelType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> const unsigned int Dimension = 3;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::Image< PixelType, Dimension > ImageType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::Image< float, 3 > ImageType;</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">// image origin</FONT>
<BR><FONT SIZE=2 FACE="Arial"> float ox = 0.0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> float oy = 0.0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> float oz = 0.0;</FONT>
<BR><FONT SIZE=2 FACE="Arial">// pixel spacing</FONT>
<BR><FONT SIZE=2 FACE="Arial"> float dx = 1.0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> float dy = 1.0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> float dz = 1.0;</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> ImageType::Pointer itkimage = ImageType::New();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> ImageType::SizeType size; size[0] = xdim; size[1] = ydim;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> size[2] = zdim;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> ImageType::IndexType start; start[0] = 0; start[1] = 0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> start[2] = 0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> ImageType::RegionType region; region.SetSize( size ); region.SetIndex( start ); itkimage->SetRegions( region);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> itkimage->Allocate();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> double spacing[3]; spacing[0] = dx; spacing[1] = dy;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> spacing[2] = dz; itkimage->SetSpacing( spacing );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> double origin[3]; origin[0] = ox; origin[1] = oy;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> origin[2] = oz; itkimage->SetOrigin( origin );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::ImageRegionIterator< ImageType> IteratorType; IteratorType it( itkimage, region ); it.GoToBegin(); float * data = ddvimage; while( ! it.IsAtEnd() ) { it.Set( *data); ++it; ++data; }</FONT></P>
<P><FONT SIZE=2 FACE="Arial">// ****************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// End preliminaries *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// ****************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// typedef itk::RescaleIntensityImageFilter< </FONT>
<BR><FONT SIZE=2 FACE="Arial">// ImageType, ImageType > preRescaleFilterType;</FONT>
<BR><FONT SIZE=2 FACE="Arial">// preRescaleFilterType::Pointer prerescaler = preRescaleFilterType::New();</FONT>
<BR><FONT SIZE=2 FACE="Arial">// prerescaler->SetOutputMinimum( 0 );</FONT>
<BR><FONT SIZE=2 FACE="Arial">// prerescaler->SetOutputMaximum( 255 );</FONT>
<BR><FONT SIZE=2 FACE="Arial">// prerescaler->SetInput( itkimage );</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// SIGNED DISTANCE MAP WITH AUTOMATIC RESCALING</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef float OutputPixelType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::Image< OutputPixelType, 3 > OutputImageType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::SignedDanielssonDistanceMapImageFilter<</FONT>
<BR><FONT SIZE=2 FACE="Arial"> ImageType, </FONT>
<BR><FONT SIZE=2 FACE="Arial"> OutputImageType > FilterType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> FilterType::Pointer filter = FilterType::New(); </FONT>
<BR><FONT SIZE=2 FACE="Arial"> filter->SetInput( itkimage );</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> typedef itk::RescaleIntensityImageFilter< </FONT>
<BR><FONT SIZE=2 FACE="Arial"> OutputImageType, OutputImageType > RescaleFilterType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> RescaleFilterType::Pointer rescaler = RescaleFilterType::New();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> rescaler->SetOutputMinimum( 0L );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> rescaler->SetOutputMaximum( 65535L );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> rescaler->SetInput( filter->GetOutput() );</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// End Filter *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// Begin Conclusion: This writes the image back to the local *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// buffer and should be written as a generic callable function *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial"> 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();</FONT></P>
<P><FONT SIZE=2 FACE="Arial">// </FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">printf("done ITK Signed Danielsson Distance Map\n");</FONT>
<BR><FONT SIZE=2 FACE="Arial"> if ( pd ) {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> delete pd;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> QApplication::restoreOverrideCursor(); </FONT>
<BR><FONT SIZE=2 FACE="Arial"> }</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">}</FONT>
<BR><FONT FACE="Times New Roman">Daniel R Einstein, PhD<BR>
Biological Monitoring and Modeling<BR>
Pacific Northwest National Laboratory<BR>
P.O. Box 999; MSIN P7-58<BR>
Richland, WA 99352<BR>
Tel: 509/ 376-2924<BR>
Fax: 509/376-9064<BR>
</FONT><A HREF="mailto:daniel.einstein@pnl.gov"><U><FONT COLOR="#0000FF" FACE="Times New Roman">daniel.einstein@pnl.gov</FONT></U></A>
</P>
<BR>
<BR>
<P><FONT FACE="Times New Roman">Daniel R Einstein, PhD<BR>
Biological Monitoring and Modeling<BR>
Pacific Northwest National Laboratory<BR>
P.O. Box 999; MSIN P7-58<BR>
Richland, WA 99352<BR>
Tel: 509/ 376-2924<BR>
Fax: 509/376-9064<BR>
</FONT><A HREF="mailto:daniel.einstein@pnl.gov"><U><FONT COLOR="#0000FF" FACE="Times New Roman">daniel.einstein@pnl.gov</FONT></U></A>
</P>
<BR>
</BODY>
</HTML>