本文整理汇总了C++中typenameimagetype::Pointer::GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetOrigin方法的具体用法?C++ Pointer::GetOrigin怎么用?C++ Pointer::GetOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenameimagetype::Pointer
的用法示例。
在下文中一共展示了Pointer::GetOrigin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetVoxelSpaceToRASPhysicalSpaceMatrix
TransformMatrixType GetVoxelSpaceToRASPhysicalSpaceMatrix(typename ImageType::Pointer image)
{
// Generate intermediate terms
vnl_matrix<double> m_dir, m_ras_matrix;
vnl_diag_matrix<double> m_scale, m_lps_to_ras;
vnl_vector<double> v_origin, v_ras_offset;
// Compute the matrix
m_dir = image->GetDirection().GetVnlMatrix();
m_scale.set(image->GetSpacing().GetVnlVector());
m_lps_to_ras.set(vnl_vector<double>(ImageType::ImageDimension, 1.0));
m_lps_to_ras[0] = -1;
m_lps_to_ras[1] = -1;
m_ras_matrix = m_lps_to_ras * m_dir * m_scale;
// Compute the vector
v_origin = image->GetOrigin().GetVnlVector();
v_ras_offset = m_lps_to_ras * v_origin;
// Create the larger matrix
TransformMatrixType mat;
vnl_vector<double> vcol(ImageType::ImageDimension+1, 1.0);
vcol.update(v_ras_offset);
mat.SetIdentity();
mat.GetVnlMatrix().update(m_ras_matrix);
mat.GetVnlMatrix().set_column(ImageType::ImageDimension, vcol);
return mat;
}
示例2: operator
void operator()(Parameters& params)
{
typedef typename ::itk::Image< PIXELTYPE, 3 > ImageType;
const typename ImageType::Pointer itkImage = ::fwItkIO::itkImageFactory< ImageType >(params.i_image);
typename ::itk::ResampleImageFilter<ImageType, ImageType>::Pointer resampler =
::itk::ResampleImageFilter<ImageType, ImageType>::New();
typename ::itk::MinimumMaximumImageCalculator< ImageType >::Pointer minCalculator =
::itk::MinimumMaximumImageCalculator< ImageType >::New();
minCalculator->SetImage(itkImage);
minCalculator->ComputeMinimum();
resampler->SetDefaultPixelValue(minCalculator->GetMinimum());
resampler->SetTransform(params.i_trf.GetPointer());
resampler->SetInput(itkImage);
typename ImageType::SizeType size = itkImage->GetLargestPossibleRegion().GetSize();
typename ImageType::PointType origin = itkImage->GetOrigin();
typename ImageType::SpacingType spacing = itkImage->GetSpacing();
typename ImageType::DirectionType direction = itkImage->GetDirection();
SLM_ASSERT("Input spacing can't be null along any axis", spacing[0] > 0 && spacing[1] > 0 && spacing[2] > 0);
if(params.i_targetImage)
{
for(std::uint8_t i = 0; i < 3; ++i)
{
// ITK uses unsigned long to store sizes.
size[i] = static_cast<typename ImageType::SizeType::SizeValueType>(params.i_targetImage->getSize()[i]);
origin[i] = params.i_targetImage->getOrigin()[i];
spacing[i] = params.i_targetImage->getSpacing()[i];
SLM_ASSERT("Output spacing can't be null along any axis.", spacing[i] > 0);
}
}
resampler->SetSize(size);
resampler->SetOutputOrigin(origin);
resampler->SetOutputDirection(direction);
resampler->SetOutputSpacing(spacing);
resampler->Update();
typename ImageType::Pointer outputImage = resampler->GetOutput();
::fwItkIO::itkImageToFwDataImage(outputImage, params.o_image);
}
示例3: update
template <class ImagePixelType, class MaskPixelType> int update()
{
typedef itk::Image<ImagePixelType, 3> ImageType;
typedef itk::Image<MaskPixelType, 3> MaskType;
if ( !input ||!input->data() || !mask ||!mask->data())
return EXIT_FAILURE;
typedef itk::MaskImageFilter< ImageType, MaskType> MaskFilterType;
typename MaskFilterType::Pointer maskFilter = MaskFilterType::New();
typename ImageType::Pointer imgInput = dynamic_cast<ImageType *> ( ( itk::Object* ) ( input->data() )) ;
typename MaskType::Pointer maskInput = dynamic_cast<MaskType *> ( ( itk::Object* ) ( mask->data() )) ;
try
{
maskInput->SetOrigin(imgInput->GetOrigin());
maskInput->SetSpacing(imgInput->GetSpacing());
maskFilter->SetInput(imgInput);
maskFilter->SetMaskingValue(maskBackgroundValue);
maskFilter->SetMaskImage(maskInput);
//Outside values set to the lowest reachable value
typedef itk::MinimumMaximumImageCalculator <ImageType> ImageCalculatorFilterType;
typename ImageCalculatorFilterType::Pointer imageCalculatorFilter
= ImageCalculatorFilterType::New ();
imageCalculatorFilter->SetImage(imgInput);
imageCalculatorFilter->ComputeMinimum();
maskFilter->SetOutsideValue(std::min(double(imageCalculatorFilter->GetMinimum()), 0.0));
maskFilter->Update();
output->setData(maskFilter->GetOutput());
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught in medMaskApplication!" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
medUtilities::setDerivedMetaData(output, input, "masked");
return EXIT_SUCCESS;
}
示例4: if
template <class inputType, unsigned int Dimension> medAbstractJob::medJobExitStatus medItkBiasCorrectionProcess::N4BiasCorrectionCore()
{
medJobExitStatus eRes = medAbstractJob::MED_JOB_EXIT_SUCCESS;
typedef itk::Image<inputType, Dimension > ImageType;
typedef itk::Image <float, Dimension> OutputImageType;
typedef itk::Image<unsigned char, Dimension> MaskImageType;
typedef itk::N4BiasFieldCorrectionImageFilter<OutputImageType, MaskImageType, OutputImageType> BiasFilter;
typedef itk::ConstantPadImageFilter<OutputImageType, OutputImageType> PadderType;
typedef itk::ConstantPadImageFilter<MaskImageType, MaskImageType> MaskPadderType;
typedef itk::ShrinkImageFilter<OutputImageType, OutputImageType> ShrinkerType;
typedef itk::ShrinkImageFilter<MaskImageType, MaskImageType> MaskShrinkerType;
typedef itk::BSplineControlPointImageFilter<typename BiasFilter::BiasFieldControlPointLatticeType, typename BiasFilter::ScalarImageType> BSplinerType;
typedef itk::ExpImageFilter<OutputImageType, OutputImageType> ExpFilterType;
typedef itk::DivideImageFilter<OutputImageType, OutputImageType, OutputImageType> DividerType;
typedef itk::ExtractImageFilter<OutputImageType, OutputImageType> CropperType;
unsigned int uiThreadNb = static_cast<unsigned int>(m_poUIThreadNb->value());
unsigned int uiShrinkFactors = static_cast<unsigned int>(m_poUIShrinkFactors->value());
unsigned int uiSplineOrder = static_cast<unsigned int>(m_poUISplineOrder->value());
float fWienerFilterNoise = static_cast<float>(m_poFWienerFilterNoise->value());
float fbfFWHM = static_cast<float>(m_poFbfFWHM->value());
float fConvergenceThreshold = static_cast<float>(m_poFConvergenceThreshold->value());
float fSplineDistance = static_cast<float>(m_poFSplineDistance->value());
float fProgression = 0;
QStringList oListValue = m_poSMaxIterations->value().split("x");
std::vector<unsigned int> oMaxNumbersIterationsVector(oListValue.size());
std::vector<float> oInitialMeshResolutionVect(Dimension);
for (int i=0; i<oMaxNumbersIterationsVector.size(); ++i)
{
oMaxNumbersIterationsVector[i] = (unsigned int)oListValue[i].toInt();
}
oInitialMeshResolutionVect[0] = static_cast<float>(m_poFInitialMeshResolutionVect1->value());
oInitialMeshResolutionVect[1] = static_cast<float>(m_poFInitialMeshResolutionVect2->value());
oInitialMeshResolutionVect[2] = static_cast<float>(m_poFInitialMeshResolutionVect3->value());
typename ImageType::Pointer image = dynamic_cast<ImageType *>((itk::Object*)(this->input()->data()));
typedef itk::CastImageFilter <ImageType, OutputImageType> CastFilterType;
typename CastFilterType::Pointer castFilter = CastFilterType::New();
castFilter->SetInput(image);
/********************************************************************************/
/***************************** PREPARING STARTING *******************************/
/********************************************************************************/
/*** 0 ******************* Create filter and accessories ******************/
ABORT_CHECKING(m_bAborting);
typename BiasFilter::Pointer filter = BiasFilter::New();
typename BiasFilter::ArrayType oNumberOfControlPointsArray;
m_filter = filter;
/*** 1 ******************* Read input image *******************************/
ABORT_CHECKING(m_bAborting);
fProgression = 1;
updateProgression(fProgression);
/*** 2 ******************* Creating Otsu mask *****************************/
ABORT_CHECKING(m_bAborting);
itk::TimeProbe timer;
timer.Start();
typename MaskImageType::Pointer maskImage = ITK_NULLPTR;
typedef itk::OtsuThresholdImageFilter<OutputImageType, MaskImageType> ThresholderType;
typename ThresholderType::Pointer otsu = ThresholderType::New();
m_filter = otsu;
otsu->SetInput(castFilter->GetOutput());
otsu->SetNumberOfHistogramBins(200);
otsu->SetInsideValue(0);
otsu->SetOutsideValue(1);
otsu->SetNumberOfThreads(uiThreadNb);
otsu->Update();
updateProgression(fProgression);
maskImage = otsu->GetOutput();
/*** 3A *************** Set Maximum number of Iterations for the filter ***/
ABORT_CHECKING(m_bAborting);
typename BiasFilter::VariableSizeArrayType itkTabMaximumIterations;
itkTabMaximumIterations.SetSize(oMaxNumbersIterationsVector.size());
for (int i = 0; i < oMaxNumbersIterationsVector.size(); ++i)
{
itkTabMaximumIterations[i] = oMaxNumbersIterationsVector[i];
}
filter->SetMaximumNumberOfIterations(itkTabMaximumIterations);
/*** 3B *************** Set Fitting Levels for the filter *****************/
typename BiasFilter::ArrayType oFittingLevelsTab;
oFittingLevelsTab.Fill(oMaxNumbersIterationsVector.size());
filter->SetNumberOfFittingLevels(oFittingLevelsTab);
updateProgression(fProgression);
/*** 4 ******************* Save image's index, size, origine **************/
ABORT_CHECKING(m_bAborting);
typename ImageType::IndexType oImageIndex = image->GetLargestPossibleRegion().GetIndex();
typename ImageType::SizeType oImageSize = image->GetLargestPossibleRegion().GetSize();
typename ImageType::PointType newOrigin = image->GetOrigin();
//.........这里部分代码省略.........