当前位置: 首页>>代码示例>>C++>>正文


C++ PointType::GetVectorFromOrigin方法代码示例

本文整理汇总了C++中PointType::GetVectorFromOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ PointType::GetVectorFromOrigin方法的具体用法?C++ PointType::GetVectorFromOrigin怎么用?C++ PointType::GetVectorFromOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PointType的用法示例。


在下文中一共展示了PointType::GetVectorFromOrigin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void
  CalculateLargestDiameter(itk::Image<TPixel, VImageDimension>* mask, mitk::Image::Pointer valueImage, mitk::GIFVolumetricStatistics::FeatureListType & featureList, std::string prefix)
{
  typedef itk::Image<double, VImageDimension> ValueImageType;

  typename ValueImageType::Pointer itkValueImage = ValueImageType::New();
  mitk::CastToItkImage(valueImage, itkValueImage);

  typedef itk::Image<TPixel, VImageDimension> ImageType;
  typedef typename ImageType::PointType PointType;
  typename ImageType::SizeType radius;
  for (int i=0; i < (int)VImageDimension; ++i)
    radius[i] = 1;
  itk::NeighborhoodIterator<ImageType> iterator(radius, mask, mask->GetRequestedRegion());
  itk::NeighborhoodIterator<ValueImageType> valueIter(radius, itkValueImage, itkValueImage->GetRequestedRegion());
  std::vector<PointType> borderPoints;

  unsigned int maskDimensionX = mask->GetLargestPossibleRegion().GetSize()[0];
  unsigned int maskDimensionY = mask->GetLargestPossibleRegion().GetSize()[1];
  unsigned int maskDimensionZ = mask->GetLargestPossibleRegion().GetSize()[2];

  double maskVoxelSpacingX = mask->GetSpacing()[0];
  double maskVoxelSpacingY = mask->GetSpacing()[1];
  double maskVoxelSpacingZ = mask->GetSpacing()[2];

  int maskMinimumX = maskDimensionX;
  int maskMaximumX = 0;
  int maskMinimumY = maskDimensionY;
  int maskMaximumY = 0;
  int maskMinimumZ = maskDimensionZ;
  int maskMaximumZ = 0;

  //
  //  Calculate surface in different directions
  //
  double surface = 0;
  std::vector<double> directionSurface;
  for (int i = 0; i < (int)(iterator.Size()); ++i)
  {
    auto offset = iterator.GetOffset(i);
    double deltaS = 1;
    int nonZeros = 0;
    for (unsigned int j = 0; j < VImageDimension; ++j)
    {
      if (offset[j] != 0 && nonZeros == 0)
      {
        for (unsigned int k = 0; k < VImageDimension; ++k)
        {
          if (k != j)
            deltaS *= mask->GetSpacing()[k];
        }
        nonZeros++;
      }
      else if (offset[j] != 0)
      {
        deltaS = 0;
      }
    }
    if (nonZeros < 1)
      deltaS = 0;
    directionSurface.push_back(deltaS);
  }

  //
  // Prepare calulation of Centre of mass shift
  //
  PointType normalCenter(0);
  PointType normalCenterUncorrected(0);
  PointType weightedCenter(0);
  PointType currentPoint;
  int numberOfPoints = 0;
  int numberOfPointsUncorrected = 0;
  double sumOfPoints = 0;

  while(!iterator.IsAtEnd())
  {
    if (iterator.GetCenterPixel() == 0)
    {
      ++iterator;
      ++valueIter;
      continue;
    }

    maskMinimumX = (maskMinimumX > iterator.GetIndex()[0]) ? iterator.GetIndex()[0] : maskMinimumX;
    maskMaximumX = (maskMaximumX < iterator.GetIndex()[0]) ? iterator.GetIndex()[0] : maskMaximumX;
    maskMinimumY = (maskMinimumY > iterator.GetIndex()[1]) ? iterator.GetIndex()[1] : maskMinimumY;
    maskMaximumY = (maskMaximumY < iterator.GetIndex()[1]) ? iterator.GetIndex()[1] : maskMaximumY;
    maskMinimumZ = (maskMinimumZ > iterator.GetIndex()[2]) ? iterator.GetIndex()[2] : maskMinimumZ;
    maskMaximumZ = (maskMaximumZ < iterator.GetIndex()[2]) ? iterator.GetIndex()[2] : maskMaximumZ;

    mask->TransformIndexToPhysicalPoint(iterator.GetIndex(), currentPoint);

    normalCenterUncorrected += currentPoint.GetVectorFromOrigin();
    ++numberOfPointsUncorrected;

    double intensityValue = valueIter.GetCenterPixel();
    if (intensityValue == intensityValue)
    {
      normalCenter += currentPoint.GetVectorFromOrigin();
      weightedCenter += currentPoint.GetVectorFromOrigin() * intensityValue;
//.........这里部分代码省略.........
开发者ID:Cdebus,项目名称:MITK,代码行数:101,代码来源:mitkGIFVolumetricStatistics.cpp


注:本文中的PointType::GetVectorFromOrigin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。