#ifndef _itkUnaryRetractImageFilter_txx #define _itkUnaryRetractImageFilter_txx #include "itkUnaryRetractImageFilter.h" #include "itkImageLinearConstIteratorWithIndex.h" namespace itk { template UnaryRetractImageFilter:: UnaryRetractImageFilter() {} // check input template void UnaryRetractImageFilter:: GenerateOutputInformation() { const unsigned int dimI=InputImageDimension; const unsigned int dimO=OutputImageDimension; if (dimI<1 || dimOGetOutput(0); InputImagePointer inputPtr = dynamic_cast(ProcessObject::GetInput(0)); InputImageRegionType regionI=inputPtr->GetRequestedRegion(); InputImageSizeType sizeI = regionI.GetSize(); InputImageIndexType indexI = regionI.GetIndex(); InputImageOriginType originI = inputPtr->GetOrigin(); InputImageSpacingType spacingI = inputPtr->GetSpacing(); OutputImageSizeType sizeO; OutputImageIndexType indexO; OutputImageOriginType originO; OutputImageSpacingType spacingO; for (int i=0; iSetOrigin(originO); outputPtr->SetSpacing(spacingO); outputPtr->SetRegions(regionO); // pass tags: InputImagePointer inputPtr0 = dynamic_cast(ProcessObject::GetInput(0)); outputPtr->SetMetaDataDictionary(inputPtr0->GetMetaDataDictionary()); } // retract input template void UnaryRetractImageFilter:: GenerateData() { const unsigned int dimI=InputImageDimension; const unsigned int dimO=OutputImageDimension; OutputImagePointer outputPtr = this->GetOutput(0); InputImagePointer inputPtr = dynamic_cast(ProcessObject::GetInput(0)); inputPtr->Update(); outputPtr->Allocate(); const unsigned int runLength=inputPtr->GetBufferedRegion().GetSize()[dimI-1]; // get time point list from meta dictionary: typedef MetaDataDictionary DictionaryType; DictionaryType &metaDict=inputPtr->GetMetaDataDictionary(); std::string internalId="___internal-4D-filter-time-point-list"; // internal tag MetaDataDictionary::ConstIterator tagItr=metaDict.Find(internalId); ExceptionObject ex("invalid time point list"); Array timePoints; timePoints.SetSize(runLength); if (tagItr!=metaDict.End()) { typedef MetaDataObject< std::list > MetaDataListType; MetaDataObjectBase::Pointer entry = tagItr->second; MetaDataListType::Pointer entryvalue = dynamic_cast( entry.GetPointer() ); // check whether or not the type of the entry value is correct if (entryvalue) { std::list list; list=entryvalue->GetMetaDataObjectValue(); if (list.size()!=runLength) throw ex; std::list::const_iterator listItr=list.begin(); for (int k=0; k IteratorType; // process input by retrieving one time series after another: IteratorType itr(inputPtr, inputPtr->GetBufferedRegion()); itr.SetDirection(dimI-1); // walk along highest dimension itr.GoToBegin(); InputImageIndexType indexI; OutputImageIndexType indexO; for (int i=dimI-1; iSetPixel(indexO, static_cast(m_Functor(naryInputArray,timePoints))); itr.NextLine(); } } } #endif