本文整理汇总了C++中image::Pointer::GetTimeSlicedGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetTimeSlicedGeometry方法的具体用法?C++ Pointer::GetTimeSlicedGeometry怎么用?C++ Pointer::GetTimeSlicedGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::Pointer
的用法示例。
在下文中一共展示了Pointer::GetTimeSlicedGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void mitk::GeometryClipImageFilter::GenerateData()
{
Image::ConstPointer input = this->GetInput();
Image::Pointer output = this->GetOutput();
if((output->IsInitialized()==false) || (m_ClippingGeometry.IsNull()))
return;
const Geometry2D * clippingGeometryOfCurrentTimeStep = NULL;
if(m_TimeSlicedClippingGeometry.IsNull())
{
clippingGeometryOfCurrentTimeStep = dynamic_cast<const Geometry2D*>(m_ClippingGeometry.GetPointer());
}
else
{
clippingGeometryOfCurrentTimeStep = dynamic_cast<const Geometry2D*>(m_TimeSlicedClippingGeometry->GetGeometry3D(0));
}
if(clippingGeometryOfCurrentTimeStep == NULL)
return;
m_InputTimeSelector->SetInput(input);
m_OutputTimeSelector->SetInput(this->GetOutput());
mitk::Image::RegionType outputRegion = output->GetRequestedRegion();
const mitk::TimeSlicedGeometry *outputTimeGeometry = output->GetTimeSlicedGeometry();
const mitk::TimeSlicedGeometry *inputTimeGeometry = input->GetTimeSlicedGeometry();
ScalarType timeInMS;
int timestep=0;
int tstart=outputRegion.GetIndex(3);
int tmax=tstart+outputRegion.GetSize(3);
int t;
for(t=tstart;t<tmax;++t)
{
timeInMS = outputTimeGeometry->TimeStepToMS( t );
timestep = inputTimeGeometry->MSToTimeStep( timeInMS );
m_InputTimeSelector->SetTimeNr(timestep);
m_InputTimeSelector->UpdateLargestPossibleRegion();
m_OutputTimeSelector->SetTimeNr(t);
m_OutputTimeSelector->UpdateLargestPossibleRegion();
if(m_TimeSlicedClippingGeometry.IsNotNull())
{
timestep = m_TimeSlicedClippingGeometry->MSToTimeStep( timeInMS );
if(m_TimeSlicedClippingGeometry->IsValidTime(timestep) == false)
continue;
clippingGeometryOfCurrentTimeStep = dynamic_cast<const Geometry2D*>(m_TimeSlicedClippingGeometry->GetGeometry3D(timestep));
}
AccessByItk_2(m_InputTimeSelector->GetOutput(),_InternalComputeClippedImage,this,clippingGeometryOfCurrentTimeStep);
}
m_TimeOfHeaderInitialization.Modified();
}
示例2: itkExceptionMacro
void mitk::CorrectorAlgorithm::GenerateData()
{
Image::Pointer inputImage = const_cast<Image*>(ImageToImageFilter::GetInput(0));
if (inputImage.IsNull() || inputImage->GetDimension() != 2)
{
itkExceptionMacro("CorrectorAlgorithm needs a 2D image as input.");
}
if (m_Contour.IsNull())
{
itkExceptionMacro("CorrectorAlgorithm needs a Contour object as input.");
}
// copy the input (since m_WorkingImage will be changed later)
m_WorkingImage = Image::New();
m_WorkingImage->Initialize( inputImage );
m_WorkingImage->SetVolume( inputImage.GetPointer()->GetData() );
if (inputImage->GetTimeSlicedGeometry() )
{
AffineGeometryFrame3D::Pointer originalGeometryAGF = inputImage->GetTimeSlicedGeometry()->Clone();
TimeSlicedGeometry::Pointer originalGeometry = dynamic_cast<TimeSlicedGeometry*>( originalGeometryAGF.GetPointer() );
m_WorkingImage->SetGeometry( originalGeometry );
}
else
{
itkExceptionMacro("Original image does not have a 'Time sliced geometry'! Cannot copy.");
}
// Convert to ipMITKSegmentationTYPE (because TobiasHeimannCorrectionAlgorithm relys on that data type)
itk::Image< ipMITKSegmentationTYPE, 2 >::Pointer correctPixelTypeImage;
CastToItkImage( m_WorkingImage, correctPixelTypeImage );
assert (correctPixelTypeImage.IsNotNull() );
// possible bug in CastToItkImage ?
// direction maxtrix is wrong/broken/not working after CastToItkImage, leading to a failed assertion in
// mitk/Core/DataStructures/mitkSlicedGeometry3D.cpp, 479:
// virtual void mitk::SlicedGeometry3D::SetSpacing(const mitk::Vector3D&): Assertion `aSpacing[0]>0 && aSpacing[1]>0 && aSpacing[2]>0' failed
// solution here: we overwrite it with an unity matrix
itk::Image< ipMITKSegmentationTYPE, 2 >::DirectionType imageDirection;
imageDirection.SetIdentity();
correctPixelTypeImage->SetDirection(imageDirection);
Image::Pointer temporarySlice = this->GetOutput();
// temporarySlice = ImportItkImage( correctPixelTypeImage );
CastToMitkImage( correctPixelTypeImage, temporarySlice );
TobiasHeimannCorrectionAlgorithm( temporarySlice->GetSliceData()->GetPicDescriptor() );
// temporarySlice is our return value (user can get it by calling GetOutput() )
CalculateDifferenceImage( temporarySlice, inputImage );
if ( m_DifferenceImage.IsNotNull() && inputImage->GetTimeSlicedGeometry() )
{
AffineGeometryFrame3D::Pointer originalGeometryAGF = inputImage->GetTimeSlicedGeometry()->Clone();
TimeSlicedGeometry::Pointer originalGeometry = dynamic_cast<TimeSlicedGeometry*>( originalGeometryAGF.GetPointer() );
m_DifferenceImage->SetGeometry( originalGeometry );
}
else
{
itkExceptionMacro("Original image does not have a 'Time sliced geometry'! Cannot copy.");
}
}