/*------------------------------------------------------------------------- Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html 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 CLITKIMAGEFILLREGIONGENERICFILTER_TXX #define CLITKIMAGEFILLREGIONGENERICFILTER_TXX /*------------------------------------------------- * @file clitkImageFillRegionGenericFilter.txx * @author Cristina Gimenez * @date 9 August 2006 * -------------------------------------------------*/ //-------------------------------------------------------------------- template void ImageFillRegionGenericFilter::Update_WithDim() { #define TRY_TYPE(TYPE) \ if (IsSameType(mPixelTypeName)) { Update_WithDimAndPixelType(); return; } // TRY_TYPE(signed char); // TRY_TYPE(uchar); TRY_TYPE(short); //TRY_TYPE(ushort); // TRY_TYPE(int); // TRY_TYPE(unsigned int); TRY_TYPE(float); // TRY_TYPE(double); #undef TRY_TYPE std::string list = CreateListOfTypes(); std::cerr << "Error, I don't know the type '" << mPixelTypeName << "' for the input image '" << mInputFilenames[0] << "'." << std::endl << "Known types are " << list << std::endl; exit(0); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template void ImageFillRegionGenericFilter::Update_WithDimAndPixelType() { // Spheric region if (mSphericRegion) return Update_WithDimAndPixelType_SphericRegion(); // Read input typedef itk::Image ImageType; typename ImageType::Pointer input = GetInput(0); // Get pixel value in correct type PixelType value = PixelTypeDownCast(mPixelValue); // Get region typedef typename ImageType::RegionType RegionType; typedef typename ImageType::SizeType SizeType; typedef typename ImageType::IndexType IndexType; RegionType region; SizeType size; IndexType start; for(unsigned int i=0; i IteratorType; IteratorType it(input, region); it.GoToBegin(); while (!it.IsAtEnd()) { it.Set(value); ++it; } // Write results SetNextOutput(input); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template void ImageFillRegionGenericFilter::Update_WithDimAndPixelType_SphericRegion() { // Read input typedef itk::Image ImageType; //typename ImageType::Pointer input = clitk::readImage(mInputFilenames[0], mIOVerbose); typename ImageType::Pointer input = GetInput(0); // Get pixel value in correct type PixelType value = PixelTypeDownCast(mPixelValue); // Centered? if(m_IsCentered) { typename ImageType::SizeType size= input->GetLargestPossibleRegion().GetSize(); typename ImageType::SpacingType spacing= input->GetSpacing(); typename ImageType::PointType origin= input->GetOrigin(); mCenter.resize(Dim); for (unsigned int i=0; i IteratorType; IteratorType it(input, input->GetLargestPossibleRegion()); it.GoToBegin(); typename ImageType::PointType point; //typename itk::Vector distance; typename ImageType::IndexType index; //bool inside; double distance; while (!it.IsAtEnd()) { // inside=true; index=it.GetIndex(); input->TransformIndexToPhysicalPoint(index, point); distance=0.0; for(unsigned int i=0; i(input); } //-------------------------------------------------------------------- #endif //#define CLITKIMAGEFILLREGIONGENERICFILTER_TXX