本文整理汇总了C++中inputimagetype::Pointer::GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetOrigin方法的具体用法?C++ Pointer::GetOrigin怎么用?C++ Pointer::GetOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inputimagetype::Pointer
的用法示例。
在下文中一共展示了Pointer::GetOrigin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResampleBySpacing
static mitk::Image::Pointer ResampleBySpacing(mitk::Image *input, float *spacing, bool useLinInt = true, bool useNN = false)
{
if (!useNN)
{
InputImageType::Pointer itkImage = InputImageType::New();
CastToItkImage(input,itkImage);
/**
* 1) Resampling
*
*/
// Identity transform.
// We don't want any transform on our image except rescaling which is not
// specified by a transform but by the input/output spacing as we will see
// later.
// So no transform will be specified.
typedef itk::IdentityTransform<double, 3> T_Transform;
// The resampler type itself.
typedef itk::ResampleImageFilter<InputImageType, InputImageType> T_ResampleFilter;
// Prepare the resampler.
// Instantiate the transform and specify it should be the id transform.
T_Transform::Pointer _pTransform = T_Transform::New();
_pTransform->SetIdentity();
// Instantiate the resampler. Wire in the transform and the interpolator.
T_ResampleFilter::Pointer _pResizeFilter = T_ResampleFilter::New();
// Specify the input.
_pResizeFilter->SetInput(itkImage);
_pResizeFilter->SetTransform(_pTransform);
// Set the output origin.
_pResizeFilter->SetOutputOrigin(itkImage->GetOrigin());
// Compute the size of the output.
// The size (# of pixels) in the output is recomputed using
// the ratio of the input and output sizes.
InputImageType::SpacingType inputSpacing = itkImage->GetSpacing();
InputImageType::SpacingType outputSpacing;
const InputImageType::RegionType& inputSize = itkImage->GetLargestPossibleRegion();
InputImageType::SizeType outputSize;
typedef InputImageType::SizeType::SizeValueType SizeValueType;
// Set the output spacing.
outputSpacing[0] = spacing[0];
outputSpacing[1] = spacing[1];
outputSpacing[2] = spacing[2];
outputSize[0] = static_cast<SizeValueType>(inputSize.GetSize()[0] * inputSpacing[0] / outputSpacing[0] + .5);
outputSize[1] = static_cast<SizeValueType>(inputSize.GetSize()[1] * inputSpacing[1] / outputSpacing[1] + .5);
outputSize[2] = static_cast<SizeValueType>(inputSize.GetSize()[2] * inputSpacing[2] / outputSpacing[2] + .5);
_pResizeFilter->SetOutputSpacing(outputSpacing);
_pResizeFilter->SetSize(outputSize);
typedef itk::LinearInterpolateImageFunction< InputImageType > LinearInterpolatorType;
LinearInterpolatorType::Pointer lin_interpolator = LinearInterpolatorType::New();
typedef itk::WindowedSincInterpolateImageFunction< InputImageType, 4> WindowedSincInterpolatorType;
WindowedSincInterpolatorType::Pointer sinc_interpolator = WindowedSincInterpolatorType::New();
if (useLinInt)
_pResizeFilter->SetInterpolator(lin_interpolator);
else
_pResizeFilter->SetInterpolator(sinc_interpolator);
_pResizeFilter->Update();
mitk::Image::Pointer image = mitk::Image::New();
image->InitializeByItk(_pResizeFilter->GetOutput());
mitk::GrabItkImageMemory( _pResizeFilter->GetOutput(), image);
return image;
}
BinaryImageType::Pointer itkImage = BinaryImageType::New();
CastToItkImage(input,itkImage);
/**
* 1) Resampling
*
*/
// Identity transform.
// We don't want any transform on our image except rescaling which is not
// specified by a transform but by the input/output spacing as we will see
// later.
// So no transform will be specified.
typedef itk::IdentityTransform<double, 3> T_Transform;
// The resampler type itself.
typedef itk::ResampleImageFilter<BinaryImageType, BinaryImageType> T_ResampleFilter;
// Prepare the resampler.
// Instantiate the transform and specify it should be the id transform.
T_Transform::Pointer _pTransform = T_Transform::New();
_pTransform->SetIdentity();
//.........这里部分代码省略.........