本文整理汇总了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;
}