/********************************************************************* itkLocalDistanceMapImageFilter.h Authors: Eric Billet, Andriy Fedorov PI: Nikos Chrisochoides Copyright (c) 2008 College of William and Mary All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the College of William and Mary nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************/ #ifndef __itkLocalDistanceMapSmoothingImageFilter_h #define __itkLocalDistanceMapSmoothingImageFilter_h #include "itkImageToImageFilter.h" #include "itkImage.h" #include "itkNumericTraits.h" namespace itk { /** \class LocalDistanceMapSmoothingImageFilter * \brief smooths a Local Distance Map using robust statistics * * Computes the robust statistic of the region around feature pixel * then sets feature pixel equal to statistic in output image * * \ingroup IntensityImageFilters */ template class ITK_EXPORT LocalDistanceMapSmoothingImageFilter : public ImageToImageFilter { public: /** Extract dimension from input and output image. */ itkStaticConstMacro(Edge1Dimension, unsigned int, TEdge1::ImageDimension); itkStaticConstMacro(Edge2Dimension, unsigned int, TEdge2::ImageDimension); itkStaticConstMacro(Distance1Dimension, unsigned int, TDistance1::ImageDimension); itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension); /** Convenient typedefs for simplifying declarations. */ typedef TEdge1 Edge1Type; typedef TEdge2 Edge2Type; typedef TDistance1 Distance1Type; typedef TOutputImage OutputImageType; typedef ImageToImageFilter< Edge1Type, OutputImageType> Superclass; /** Standard class typedefs. */ typedef LocalDistanceMapSmoothingImageFilter Self; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(LocalDistanceMapSmoothingFilter, ImageToImageFilter); /** Image typedef support. */ typedef typename Edge1Type::PixelType Edge1PixelType; typedef typename Edge2Type::PixelType Edge2PixelType; typedef typename Distance1Type::PixelType Distance1PixelType; typedef typename OutputImageType::PixelType OutputPixelType; //typedef typename NumericTraits::RealType InputRealType; typedef typename Edge1Type::RegionType Edge1RegionType; typedef typename Edge2Type::RegionType Edge2RegionType; typedef typename Distance1Type::RegionType Distance1RegionType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef ConstNeighborhoodIterator NeighborhoodIteratorType; /** Set the input files */ void SetInput1(const TEdge1 * Edge1); void SetInput2(const TEdge2 * Edge2); void SetInput3(const TDistance1 * Distance1); const Edge1Type * GetInput1(void); const Edge2Type * GetInput2(void); const Distance1Type * GetInput3(void); /** Set and get the radius of the neighborhood used for smoothing. */ itkSetMacro(Radius, short); itkGetConstReferenceMacro(Radius, short); /** Set and getthe minimum number of feature points in a window */ itkSetMacro(MinElements, short); itkGetConstReferenceMacro(MinElements, short); /**Set and get the percentage used for least trimmed squares*/ itkSetMacro(Percent, double); itkGetConstReferenceMacro(Percent, double); protected: LocalDistanceMapSmoothingImageFilter(); virtual ~LocalDistanceMapSmoothingImageFilter() {} void PrintSelf(std::ostream& os, Indent indent) const; /** LocalDistanceMapSmoothingImageFilter 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 ); private: LocalDistanceMapSmoothingImageFilter(const Self&); //purposely not implemented double GetRobustStat(std::vector distances); void operator=(const Self&); //purposely not implemented short m_Radius; short m_MinElements; double m_Percent; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkLocalDistanceMapSmoothingImageFilter.txx" #endif #endif