/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCountImageFilter.h,v $ Language: C++ Date: $Date: 2006/03/29 14:53:40 $ Version: $Revision: 1.5 $ 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 __itkLocalGrayscaleDistanceMapImageFilter_h #define __itkLocalGrayscaleDistanceMapImageFilter_h #include "itkImageToImageFilter.h" #include "itkImage.h" #include "itkNumericTraits.h" #include "itkCountImageFilter.h" /**define structure used for search index */ struct coord{ double dist; std::vector coords; bool operator<(coord const &other)const { return dist < other.dist; } }; namespace itk { /** \class LocalGrayscaleDistanceMapImageFilter * \brief computes a Grayscale Hausdorff based Local Distance Map * * Computes a grayscale image from a binary image and then outputs * an image where a given pixel is the grayscale Hausdorff distance * of the the corresponding pixels in the grayscale image. * * \ingroup IntensityImageFilters */ template class ITK_EXPORT LocalGrayscaleDistanceMapImageFilter : public ImageToImageFilter { public: /** Extract dimension from input and output image. */ itkStaticConstMacro(Edge1Dimension, unsigned int, TEdge1::ImageDimension); itkStaticConstMacro(Edge2Dimension, unsigned int, TEdge2::ImageDimension); itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension); /** Convenient typedefs for simplifying declarations. */ typedef TEdge1 Edge1Type; typedef TEdge2 Edge2Type; typedef TOutputImage OutputImageType; /** Standard class typedefs. */ typedef LocalGrayscaleDistanceMapImageFilter Self; typedef ImageToImageFilter< Edge1Type, OutputImageType> Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(LocalGrayscaleDistanceMapImageFilter, ImageToImageFilter); /** Image typedef support. */ typedef typename Edge1Type::PixelType Edge1PixelType; typedef typename Edge2Type::PixelType Edge2PixelType; typedef typename OutputImageType::PixelType OutputPixelType; typedef typename Edge1Type::RegionType Edge1RegionType; typedef typename Edge2Type::RegionType Edge2RegionType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename Edge1Type::SizeType InputSizeType; typedef ConstNeighborhoodIterator NeighborhoodIteratorType; typedef ImageRegionConstIterator< Edge1Type > IteratorTypeC; typedef ImageRegionConstIteratorWithIndex< Edge1Type > IteratorTypeI; typedef ImageRegionIterator< OutputImageType > IteratorType; typedef CountImageFilter CountFilterType; typedef MaskImageFilter MaskFilter; typedef ImageFileWriter< OutputImageType > WriterType; /** Set the input files */ void SetInput1(const TEdge1 * edge1); void SetInput2(const TEdge2 * edge2); const Edge1Type * GetInput1(void); const Edge2Type * GetInput2(void); /** Set and get the radius of the neighborhood used to search for nearest neighbor. */ itkSetMacro(MaxDef, short); itkGetConstReferenceMacro(MaxDef, short); /** Set and Get the tolerance of the grayscale algorithm. */ itkSetMacro(Tol, short); itkGetConstReferenceMacro(Tol, short); /** Set and Get the radius for creation of the grayscale images. */ itkSetMacro(Radius, short); itkGetConstReferenceMacro(Radius, short); protected: LocalGrayscaleDistanceMapImageFilter(); virtual ~LocalGrayscaleDistanceMapImageFilter() {} void PrintSelf(std::ostream& os, Indent indent) const; /** LocalGrayscaleDistanceMapImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() * routine which is called for each processing thread. The output * image data is allocated automatically by the superclass prior to * calling ThreadedGenerateData(). ThreadedGenerateData can only * write to the portion of the output image specified by the * parameter "outputRegionForThread" * */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); void BeforeThreadedGenerateData(); private: LocalGrayscaleDistanceMapImageFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented short m_MaxDef; std::vector coord_list; short m_Tol; typename Edge1Type::Pointer m_gray1; typename Edge1Type::Pointer m_gray2; short m_Radius; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkLocalGrayscaleDistanceMapImageFilter.txx" #endif #endif