/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: GreyImageWrapper.h,v $ Language: C++ Date: $Date: 2006/02/01 20:21:23 $ Version: $Revision: 1.4 $ Copyright (c) 2003 Insight 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 __GreyImageWrapper_h_ #define __GreyImageWrapper_h_ #include "ImageWrapper.h" // #include "IntensityCurveInterface.h" // #include "UnaryFunctorCache.h" // Forward references namespace itk { template class FunctionBase; template class UnaryFunctorImageFilter; }; template class UnaryFunctorCache; template class CachingUnaryFunctor; /** * \class GreyImageWrapper * \brief Image wrapper used for greyscale images in IRIS/SNAP. * * Adds ability to remap intensity from short to byte using an * arbitrary function when outputing slices. */ class GreyImageWrapper : public ImageWrapper { public: // Definition of the intensity map function typedef itk::FunctionBase IntensityMapType; // Definition for the display slice type typedef itk::Image DisplaySliceType; typedef itk::SmartPointer DisplaySlicePointer; /** * Set the intensity curve to be used for mapping * image intensities for producing slices */ void SetIntensityMapFunction(IntensityMapType *curve); /** * Get the display slice in a given direction. To change the * display slice, call parent's MoveToSlice() method */ DisplaySlicePointer GetDisplaySlice(unsigned int dim); /** Constructor initializes mappers */ GreyImageWrapper(); /** Destructor */ ~GreyImageWrapper(); private: /** * This object is passed on to the cache for intensity mapping */ class IntensityFunctor { public: /** Map a grey value */ unsigned char operator()(const GreyType &value) const; // The storage for the float->float intensity map IntensityMapType *m_IntensityMap; // Intensity mapping factors GreyType m_IntensityMin; float m_IntensityFactor; // Dummy equality operators, since there is no data here bool operator == (const IntensityFunctor &z) const { return m_IntensityMap == z.m_IntensityMap && m_IntensityFactor == z.m_IntensityFactor && m_IntensityMin == z.m_IntensityMin; } bool operator != (const IntensityFunctor &z) const { return !(*this == z); } /** * Set the range over which the input data is mapped to output data */ void SetInputRange(GreyType intensityMin,GreyType intensityMax); }; // Type of intensity function used to map 3D volume intensity into // 2D slice intensities typedef UnaryFunctorCache CacheType; typedef itk::SmartPointer CachePointer; typedef CachingUnaryFunctor CacheFunctor; // Filters applied to slices typedef itk::Image GreySliceType; typedef itk::UnaryFunctorImageFilter< GreySliceType,DisplaySliceType,CacheFunctor> IntensityFilterType; typedef itk::SmartPointer IntensityFilterPointer; /** * An instance of the private intensity mapper (this mapper wraps the * passed in float->float function to a new function that is * [min..max]->uchar) */ IntensityFunctor m_IntensityFunctor; /** * A cache used for the intensity mapping function */ CachePointer m_IntensityMapCache; /** * Filters used to remap the intensity of the slices in this image * into unsigned char images */ IntensityFilterPointer m_IntensityFilter[3]; }; #endif // __GreyImageWrapper_h_