/* * Copyright (c) ICG. All rights reserved. * See copyright.txt for more information. * * Institute for Computer Graphics and Vision * Graz, University of Technology / Austria * * * 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. * * * Project : MIPItkProjects * Module : CommonItkUtilities * Class : $RCSfile: SmallUtilityMethods.h,v $ * Language : C++ * Description : * * Author : Martin Urschler * EMail : urschler@icg.tu-graz.ac.at * Date : $Date: 2006-09-14 16:49:25 $ * Version : $Revision: 1.19 $ * Full Id : $Id: SmallUtilityMethods.h,v 1.19 2006-09-14 16:49:25 urschler Exp $ * */ #ifndef __SMALL_UTILITY_METHODS_H__ #define __SMALL_UTILITY_METHODS_H__ // include files #include "itkCastImageFilter.h" #include "commonItkTypedefs.h" // typedefs // forward declarations /** * Class Documentation. * */ template< typename TImageType1, typename TImageType2 > inline typename TImageType2::Pointer SmallUtilityMethodsCastItkVolume( const typename TImageType1::Pointer& image ) { typedef itk::CastImageFilter< TImageType1, TImageType2 > CasterType; typename CasterType::Pointer caster = CasterType::New(); caster->SetInput( image ); ITK_EXCEPTION_CHECKED( "Apply cast image filter.", caster->Update(), 0 ); return caster->GetOutput(); } template< typename TImageType > class SmallUtilityMethods { public: typedef typename TImageType::Pointer TImageTypePointer; typedef typename TImageType::ConstPointer TImageTypeConstPointer; typedef typename TImageType::PixelType TImagePixelType; typedef typename TImageType::IndexType TImageIndexType; typedef typename TImageType::SizeType TImageSizeType; typedef typename TImageType::IndexValueType TImageIndexValueType; static TImageTypePointer shrinkVolume(const TImageTypePointer& image, unsigned int shrink_factor, bool performSmoothing=true); static TImageTypePointer shrinkVolume( const TImageTypePointer& image, unsigned int shrink_factor_x, unsigned int shrink_factor_y, unsigned int shrink_factor_z, bool performSmoothing=true ); static TImageTypePointer resampleVolumeWithoutSmoothing( const TImageTypePointer& image, const TImageSizeType& new_size ); static TImageTypePointer curvFlowSmoothVolume( const TImageTypePointer& image, unsigned int nr_iterations, double time_step ); // sigmas have to be given in real world units! static TImageTypePointer gaussSmoothVolume( const TImageTypePointer& image, double sigma_x, double sigma_y, double sigma_z ); // FIXXME Combine the next two methods into one! static TImageTypePointer gaussSmoothDerivativeVolume( const TImageTypeConstPointer& image, double sigma, unsigned int direction ); static TImageTypePointer gaussSmoothDerivativeVolume( const TImageTypePointer& image, double sigma, unsigned int direction ); // sigmas have to be given in real world units! static TImageTypePointer discreteGaussSmoothVolume( const TImageTypePointer& image, double sigma_x, double sigma_y, double sigma_z ); static TImageTypePointer removeBackground( const TImageTypePointer& image, MaskImageType::Pointer& mask_image, const double replaceValue, const double lowerThreshold, const double upperThreshold ); static unsigned long countNonZeroVoxels( const TImageTypePointer& image ); static TImagePixelType getMinimumVoxelValue( const TImageTypePointer& image ); static TImagePixelType getMaximumVoxelValue( const TImageTypePointer& image ); static double getAverageGreyValueAtSamplePoints( const TImageTypePointer& image, const std::vector< TImageIndexType >& seeds ); static TImageTypePointer calculateDifferenceImage( const TImageTypePointer& image1, const TImageTypePointer& image2 ); static TImageTypePointer createNewImage( const TImageTypePointer& prototypeImage ); static DeformationFieldType::Pointer createNewZeroedDeformationField( const TImageTypePointer& prototypeImage ); static TImageTypePointer calculateCheckerboardImage( const TImageTypePointer& image1, const TImageTypePointer& image2 ); static void calculateBoundingBoxHavingHomogenousBackground( const TImageTypePointer& image, TImageIndexType& bound_box_min_index, TImageIndexType& bound_box_max_index ); static TImageTypePointer cropVolumeHavingHomogenousBackground( const TImageTypePointer& image_with_homogenous_background ); static TImageIndexType calculateCenterInBinaryImage( const TImageTypePointer& image ); private: SmallUtilityMethods(); ~SmallUtilityMethods(); }; // inline declarations #endif // __SMALL_UTILITY_METHODS_H__