本文整理汇总了C++中floatvectorimagetype::Pointer::GetPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetPixel方法的具体用法?C++ Pointer::GetPixel怎么用?C++ Pointer::GetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类floatvectorimagetype::Pointer
的用法示例。
在下文中一共展示了Pointer::GetPixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
Helpers::ScaleChannel<float>(scaledImage, channel, 0.33f, scaledImage);
}
// Scale depth channel
Helpers::ScaleChannel<float>(scaledImage, 3, 1.0f, scaledImage);
Helpers::WriteImage<FloatVectorImageType>(scaledImage, "scaled.mha");
typedef itk::ImageFileReader< Mask > MaskReaderType;
MaskReaderType::Pointer maskReader = MaskReaderType::New();
maskReader->SetFileName(maskFilename.c_str());
maskReader->Update();
Mask::Pointer finalMask = Mask::New();
ModifyMask(maskReader->GetOutput(), patchRadius, finalMask);
cout.setf(ios::showpoint);
std::vector<float> lambdas;
for(unsigned int i = 0; i <= 10; ++i)
{
lambdas.push_back(0.1f * static_cast<float>(i));
std::cout << "Using lambda " << lambdas[i] << std::endl;
}
std::shared_ptr<SelfPatchCompare> patchCompare(new SelfPatchCompare);
patchCompare->SetNumberOfComponentsPerPixel(imageReader->GetOutput()->GetNumberOfComponentsPerPixel());
//patchCompare->FunctionsToCompute.push_back(boost::bind(&SelfPatchCompare::SetPatchAverageAbsoluteSourceDifference,patchCompare,_1));
patchCompare->FunctionsToCompute.push_back(boost::bind(&SelfPatchCompare::SetPatchColorDifference,patchCompare,_1));
patchCompare->FunctionsToCompute.push_back(boost::bind(&SelfPatchCompare::SetPatchDepthDifference,patchCompare,_1));
std::ofstream fout("scores.txt");
fout.setf(ios::showpoint);
for(unsigned int lambdaId = 0; lambdaId < lambdas.size(); ++lambdaId)
{
// Inpaint
std::cout << "Inpainting with lambda = " << lambdas[lambdaId] << std::endl;
PatchPair::DepthColorLambda = lambdas[lambdaId];
CriminisiInpainting inpainting;
//inpainting.SetDebugFunctionEnterLeave(true);
inpainting.SetPatchRadius(patchRadius);
inpainting.SetImage(scaledImage);
inpainting.SetMask(finalMask);
inpainting.SetMaxForwardLookPatches(3);
inpainting.SetPatchCompare(patchCompare);
inpainting.PatchSortFunction = &SortByDepthAndColor;
//inpainting.PatchSortFunction = &SortByAverageAbsoluteDifference;
//DepthAndColorDifference = ColorDifference * Lambda + (1.0 - Lambda) * DepthDifference;
// When lambda = 0, only the depth is used
// When lambda = 1, only the color is used
inpainting.Initialize();
inpainting.Inpaint();
// Compute error
itk::ImageRegionIterator<Mask> iterator(finalMask, finalMask->GetLargestPossibleRegion());
float depthError = 0.0f;
float colorError = 0.0f;
while(!iterator.IsAtEnd())
{
if(finalMask->IsHole(iterator.GetIndex()))
{
colorError += ColorPixelDifference::Difference(scaledImage->GetPixel(iterator.GetIndex()), inpainting.GetCurrentOutputImage()->GetPixel(iterator.GetIndex()));
depthError += DepthPixelDifference::Difference(scaledImage->GetPixel(iterator.GetIndex()), inpainting.GetCurrentOutputImage()->GetPixel(iterator.GetIndex()));
}
++iterator;
}
std::cout << "colorError: " << colorError << std::endl;
std::cout << "depthError: " << depthError << std::endl;
fout << colorError << " " << depthError << std::endl;
// Unscale all channels
for(unsigned int channel = 0; channel < imageReader->GetOutput()->GetNumberOfComponentsPerPixel(); ++channel)
{
Helpers::ScaleChannel<float>(inpainting.GetCurrentOutputImage(), channel, maxValues[channel], inpainting.GetCurrentOutputImage());
}
std::stringstream ssFloat;
ssFloat.setf(ios::showpoint);
ssFloat << outputPrefix << "_float_lambda_" << lambdas[lambdaId] << ".mha";
Helpers::WriteImage<FloatVectorImageType>(inpainting.GetCurrentOutputImage(), ssFloat.str());
std::stringstream ssRGB;
ssRGB.setf(ios::showpoint);
ssRGB << outputPrefix << "_RGB_lambda_" << lambdas[lambdaId] << ".mha";
Helpers::WriteVectorImageAsRGB(inpainting.GetCurrentOutputImage(), ssRGB.str());
//Helpers::WriteVectorImageAsRGB(inpainting.GetCurrentOutputImage(), Helpers::ReplaceFileExtension(ss.str(), "png"));
}
fout.close();
return EXIT_SUCCESS;
}