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


C++ ImageRegion::GetNumberOfPixels方法代码示例

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


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

示例1: assert

float TruncatedQuadraticDifference<TImage>::Difference
(const TImage* const image, const float truncationPoint, const itk::ImageRegion<2>& region1, const itk::ImageRegion<2>& region2)
{
  assert(region1.GetSize() == region2.GetSize());
  assert(image->GetLargestPossibleRegion().IsInside(region1));
  assert(image->GetLargestPossibleRegion().IsInside(region2));

  itk::ImageRegionConstIterator<TImage> patch1Iterator(image, region1);
  itk::ImageRegionConstIterator<TImage> patch2Iterator(image, region2);

  float sumSquaredDifferences = 0;

  typename TImage::PixelType pixel1;
  typename TImage::PixelType pixel2;

  while(!patch1Iterator.IsAtEnd())
    {
    pixel1 = patch1Iterator.Get();
    pixel2 = patch2Iterator.Get();

    float squaredDifference = PixelDifferences::SumOfSquaredDifferences(pixel1, pixel2);

//       std::cout << "Source pixel: " << static_cast<unsigned int>(sourcePixel)
//                 << " target pixel: " << static_cast<unsigned int>(targetPixel)
//                 << "Difference: " << difference << " squaredDifference: " << squaredDifference << std::endl;

    // Perform the truncation
    if(sqrt(squaredDifference) > truncationPoint)
    {
      squaredDifference = truncationPoint*truncationPoint;
    }

    sumSquaredDifferences += squaredDifference;

    ++patch1Iterator;
    ++patch2Iterator;
    } // end while iterate over sourcePatch


  unsigned int numberOfPixels = region1.GetNumberOfPixels();

  float averageSSD = sumSquaredDifferences / static_cast<float>(numberOfPixels);

  return averageSSD;
}
开发者ID:daviddoria,项目名称:PatchComparison,代码行数:45,代码来源:TruncatedQuadraticDifference.hpp


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