using PixelType = unsigned int;
void
log1xViaLogImageFilter(ImageType::Pointer & image)
{
for (; !it.IsAtEnd(); ++it)
{
}
LogType::Pointer logF = LogType::New();
logF->SetInput(image);
logF->SetInPlace(true);
logF->Update();
image = logF->GetOutput();
image->DisconnectPipeline();
}
void
log1xViaParallelizeImageRegion(ImageType::Pointer & image)
{
image->GetBufferedRegion(),
for (; !it.IsAtEnd(); ++it)
{
it.Set(std::log(1 + it.Get()));
}
},
nullptr);
}
int
main(int, char *[])
{
int result = EXIT_SUCCESS;
RandomSourceType::Pointer randomImageSource = RandomSourceType::New();
randomImageSource->SetSize(region.GetSize());
randomImageSource->SetNumberOfWorkUnits(1);
randomImageSource->Update();
ImageType::Pointer image = randomImageSource->GetOutput();
image->DisconnectPipeline();
DuplicatorType::Pointer duplicator = DuplicatorType::New();
duplicator->SetInputImage(image);
duplicator->Update();
ImageType::Pointer clonedImage = duplicator->GetOutput();
clonedImage->DisconnectPipeline();
log1xViaLogImageFilter(image);
log1xViaParallelizeImageRegion(clonedImage);
unsigned diffCount = 0;
for (; !it1.IsAtEnd(); ++it1, ++it2)
{
if (it1.Get() != it2.Get())
{
std::cerr << "Pixel values are different at index " << it1.GetIndex() << it1.Get() << " vs. " << it2.Get()
<< std::endl;
diffCount++;
result = EXIT_FAILURE;
}
}
if (diffCount == 0)
{
std::cout << "LogImageFilter and ParallelizeImageRegion generate the same result." << std::endl;
}
else
{
std::cout << "Discrepancy! " << diffCount << " pixels out of " << region.GetNumberOfPixels() << " are different."
<< std::endl;
}
return result;
}