本文整理汇总了C++中mask::Pointer::ShrinkHole方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::ShrinkHole方法的具体用法?C++ Pointer::ShrinkHole怎么用?C++ Pointer::ShrinkHole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mask::Pointer
的用法示例。
在下文中一共展示了Pointer::ShrinkHole方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AcceptMatch
bool AcceptMatch(VertexDescriptorType target, VertexDescriptorType source, float& computedEnergy) const
{
//std::cout << "DilatedVarianceDifferenceAcceptanceVisitor::AcceptMatch" << std::endl;
itk::Index<2> targetPixel = ITKHelpers::CreateIndex(target);
itk::ImageRegion<2> targetRegion = ITKHelpers::GetRegionInRadiusAroundPixel(targetPixel, HalfWidth);
itk::Index<2> sourcePixel = ITKHelpers::CreateIndex(source);
itk::ImageRegion<2> sourceRegion = ITKHelpers::GetRegionInRadiusAroundPixel(sourcePixel, HalfWidth);
// Compute the functor on the pixels in the region just inside the hole in the source patch
typename TypeTraits<typename TImage::PixelType>::LargerType sourceValue;
{
Mask::Pointer originalHole = Mask::New();
ITKHelpers::ExtractRegion(MaskImage, targetRegion, originalHole.GetPointer());
Mask::Pointer shrunkHole = Mask::New();
shrunkHole->DeepCopyFrom(originalHole);
shrunkHole->ShrinkHole(5);
typedef itk::Image<bool, 2> BoolImage;
BoolImage::Pointer holeRindImage = BoolImage::New(); // "rind" like an "orange rind"
ITKHelpers::XORRegions(originalHole.GetPointer(), originalHole->GetLargestPossibleRegion(),
shrunkHole.GetPointer(), shrunkHole->GetLargestPossibleRegion(), holeRindImage.GetPointer());
std::vector<itk::Index<2> > holeRindPixels = ITKHelpers::GetPixelsWithValue(holeRindImage.GetPointer(), holeRindImage->GetLargestPossibleRegion(), true);
itk::Index<2> zeroIndex = {{0,0}};
std::vector<itk::Offset<2> > holeRindOffsets = ITKHelpers::IndicesToOffsets(holeRindPixels, zeroIndex);
std::vector<itk::Index<2> > sourceRindPixelIndices = ITKHelpers::OffsetsToIndices(holeRindOffsets, sourceRegion.GetIndex());
std::vector<typename TImage::PixelType> sourceRindPixels = ITKHelpers::GetPixelValues(Image, sourceRindPixelIndices);
sourceValue = Functor(sourceRindPixels);
}
// Compute the functor on the pixels in the region just outside the hole in the target patch
typename TypeTraits<typename TImage::PixelType>::LargerType targetValue;
{
Mask::Pointer originalHole = Mask::New();
ITKHelpers::ExtractRegion(MaskImage, targetRegion, originalHole.GetPointer());
Mask::Pointer expandedHole = Mask::New();
expandedHole->DeepCopyFrom(originalHole);
expandedHole->ExpandHole(5);
typedef itk::Image<bool, 2> BoolImage;
BoolImage::Pointer validRindImage = BoolImage::New(); // "rind" like an "orange rind"
ITKHelpers::XORRegions(originalHole.GetPointer(), originalHole->GetLargestPossibleRegion(),
expandedHole.GetPointer(), expandedHole->GetLargestPossibleRegion(), validRindImage.GetPointer());
std::vector<itk::Index<2> > validRindPixels = ITKHelpers::GetPixelsWithValue(validRindImage.GetPointer(), validRindImage->GetLargestPossibleRegion(), true);
itk::Index<2> zeroIndex = {{0,0}};
std::vector<itk::Offset<2> > validRindOffsets = ITKHelpers::IndicesToOffsets(validRindPixels, zeroIndex);
std::vector<itk::Index<2> > targetRindPixelIndices = ITKHelpers::OffsetsToIndices(validRindOffsets, targetRegion.GetIndex());
std::vector<typename TImage::PixelType> targetRindPixels = ITKHelpers::GetPixelValues(Image, targetRindPixelIndices);
targetValue = Functor(targetRindPixels);
}
// Compute the difference
computedEnergy = (targetValue - sourceValue).GetNorm();
//std::cout << this->VisitorName << " Energy: " << computedEnergy << std::endl;
if(computedEnergy < DifferenceThreshold)
{
std::cout << this->VisitorName << ": Match accepted (" << computedEnergy << " is less than " << DifferenceThreshold << ")" << std::endl << std::endl;
return true;
}
else
{
std::cout << this->VisitorName << ": Match rejected (" << computedEnergy << " is greater than " << DifferenceThreshold << ")" << std::endl << std::endl;
return false;
}
};
开发者ID:nocnokneo,项目名称:PatchBasedInpainting,代码行数:75,代码来源:DilatedSourceHoleTargetValidAcceptanceVisitor.hpp