[Insight-developers] submission: ApproximateSignedDistanceMapImageFilter

Zachary Pincus zpincus at stanford.edu
Fri Feb 4 05:52:26 EST 2005


Hello,

Here's a submission that (partially) addresses bug 737 
(http://www.itk.org/Bug/bug.php?op=show&bugid=737&pos=0 ), and ITK's 
need for a filter that can generate a signed distance map.

Such signed distance maps are required for creating PCA shape models 
with the PCAShapeModelEstimator class, which is in turn useful for 
doing anything really interesting with the 
ShapePriorSegmentationLevelSetImageFilter family of classes.

This may only be a partial solution because bug 737 requests a signed 
distance map based on the Danielsson filter. This submission returns a 
map created by using the IsoContourDistanceImageFilter and 
FastChamferDistanceImageFilter classes. The practical upshot of this 
difference is that this class is faster, but does not compute distances 
as accurately as the Danielsson filter.

Now, it's likely that for PCA shape modeling this difference in 
accuracy might not matter a whole lot: most of the action takes place 
around the narrow band near the zero-level set, which is where the 
Chamfer distance is most accurate. So perhaps this is all the solution 
that's needed. I'm not really qualified to say if it is good enough for 
all practical uses.

Finally, I know it's right around the ITK 1.10 deadline. I have no 
expectation that this should be added for 1.10, of course. It just so 
happened that I wrote the filter now.

Zach Pincus

Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine

-------------- next part --------------
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: $
  Language:  C++
  Date:      $Date: $
  Version:   $Revision: $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __itkApproximateSignedDistanceMapImageFilter_h
#define __itkApproximateSignedDistanceMapImageFilter_h

#include "itkImageToImageFilter.h"
#include "itkFastChamferDistanceImageFilter.h"
#include "itkIsoContourDistanceImageFilter.h"

namespace itk {

/** \class ApproximateSignedDistanceMapImageFilter
* \brief Create a map of the approximate signed distance from the boundaries of
* a binary image. 
*
* The ApproximateSignedDistanceMapImageFilter takes as input a binary image and
* produces a signed distance map. Each pixel value in the output contains the 
* approximate distance from that pixel to the nearest "object" in the binary
* image. This filter differs from the DanielssonDistanceMapImageFilter in that
* it calculates the distance to the "object edge" for pixels within the object.
* 
* Negative values in the output indicate that the pixel at that position is
* within an object in the input image. The absolute value of a negative pixel
* represents the approximate distance to the nearest object boundary pixel.
*
* WARNING: This filter requires that the output type be floating-point. Otherwise
* internal calculations will not be performed to the appropriate precision,
* resulting in completely incorrect (read: zero-valued) output.
*
* The distances computed by this filter are Chamfer distances, which are only
* an approximation to Euclidian distances, and are not as exact approximations
* as those calculated by the DanielssonDistanceMapImageFilter. On the other hand,
* this filter is faster.
*
* This filter requires that an "inside value" and "outside value" be set as
* parameters. The "inside value" is the intensity value of the binary image
* which corresponds to objects, and the "outside value" is the intensity of the
* background. (A typical binary image often repesents objects as black (0) and
* background as white (usually 255), or vice-versa.) Note that this filter is
* slightly faster if the inside value is less than the outside value. Otherwise
* an extra iteration through the image is required.
*
* This filter uses the FastChamferDistanceImageFilter and the 
* IsoContourDistanceImageFilter inernally to perform the distance calculations.
*
* \sa DanielssonDistanceMapImageFilter
* \sa FastChamferDistanceImageFilter, IsoContourDistanceImageFilter
*/
  
template<class TInputImage, class TOutputImage>
class ITK_EXPORT ApproximateSignedDistanceMapImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
  /** Standard typedefs */
  typedef ApproximateSignedDistanceMapImageFilter  Self;
  typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
  typedef SmartPointer<Self> Pointer;
  typedef SmartPointer<const Self> ConstPointer;

  /** Run-time type information (and related methods). */
  itkTypeMacro(ApproximateSignedDistanceMapImageFilter, ImageToImageFilter) ;

  /** standard New() method support */
  itkNewMacro(Self) ;

  /** Type for input image. */
  typedef TInputImage InputImageType;
  
  /** Type for the output image. */
  typedef TOutputImage OutputImageType;
  
  /** Type for the pixels of the input image. */
  typedef typename InputImageType::PixelType InputPixelType;
  
  /** Type for the pixels of the output image. */
  typedef typename OutputImageType::PixelType OutputPixelType;

  /** Type of input image size and size value */
  typedef typename OutputImageType::SizeType OutputSizeType;
  typedef typename OutputSizeType::SizeValueType OutputSizeValueType;
  /** The dimension of the input image. */
  itkStaticConstMacro(InputImageDimension, unsigned int,
                      InputImageType::ImageDimension);
    
  /** Pointer Type for input image. */
  typedef typename InputImageType::ConstPointer InputImagePointer;
  
  /** Pointer Type for the output image. */
  typedef typename OutputImageType::Pointer OutputImagePointer;
  
  /** Set/Get intensity value representing the interior of objects in the mask */
  itkSetMacro(InsideValue, InputPixelType);
  itkGetMacro(InsideValue, InputPixelType);
 
  /** Set/Get intensity value representing non-objects in the mask */
  itkSetMacro(OutsideValue, InputPixelType);
  itkGetMacro(OutsideValue, InputPixelType);

protected:
  ApproximateSignedDistanceMapImageFilter();
  virtual ~ApproximateSignedDistanceMapImageFilter() {};
  virtual void GenerateData();
  void PrintSelf(std::ostream& os, Indent indent) const;
  

private:
  typedef itk::IsoContourDistanceImageFilter<InputImageType, OutputImageType> IsoContourType;
  typedef itk::FastChamferDistanceImageFilter<OutputImageType, OutputImageType> ChamferType;
  typename IsoContourType::Pointer m_IsoContourFilter;
  typename ChamferType::Pointer m_ChamferFilter;
  
  InputPixelType m_InsideValue;
  InputPixelType m_OutsideValue;
  
};

} // end of namespace itk 

#ifndef ITK_MANUAL_INSTANTIATION
#include "itkApproximateSignedDistanceMapImageFilter.txx"
#endif

#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkApproximateSignedDistanceMapImageFilter.txx
Type: application/text
Size: 5132 bytes
Desc: not available
Url : http://www.itk.org/mailman/private/insight-developers/attachments/20050204/75228c22/itkApproximateSignedDistanceMapImageFilter.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkApproximateSignedDistanceMapImageFilterTest.cxx
Type: application/octet-stream
Size: 4550 bytes
Desc: not available
Url : http://www.itk.org/mailman/private/insight-developers/attachments/20050204/75228c22/itkApproximateSignedDistanceMapImageFilterTest.obj


More information about the Insight-developers mailing list