#include <iostream>
#include <stdlib.h>
int
main(int argc, char * argv[])
{
if (argc < 2)
{
std::cerr << "Usage: N4BiasFieldCorrection inputImage outputImage";
std::cerr << " [shrinkFactor] [maskImage] [numberOfIterations]";
std::cerr << " [numberOfFittingLevels]\n";
return 1;
}
if (argc > 4)
{
}
else
{
}
unsigned int shrinkFactor = 1;
if (argc > 3)
{
shrinkFactor = atoi(argv[3]);
std::vector<unsigned int> shrink(inputImage.
GetDimension(), shrinkFactor);
}
unsigned int numFittingLevels = 4;
if (argc > 6)
{
numFittingLevels = atoi(argv[6]);
}
if (argc > 5)
{
unsigned int it = atoi(argv[5]);
std::vector<unsigned int> iterations(numFittingLevels, it);
}
if (shrinkFactor > 1)
{
sitk::WriteImage(corrected_image,
"CXX-Example-N4BiasFieldCorrection-shrunk.nrrd");
}
if (getenv("SITK_NOSHOW") == NULL)
return 0;
}
The Image class for SimpleITK.
unsigned int GetDimension() const
Implementation of the N4 bias field correction algorithm.
Image Execute(const Image &image, const Image &maskImage)
Image GetLogBiasFieldAsImage(Image referenceImage) const
The computed log bias field correction. Typically, a reduced size image is used as input to the N4 fi...
Self & SetMaximumNumberOfIterations(std::vector< uint32_t > MaximumNumberOfIterations)
SITKIO_EXPORT Image ReadImage(const PathType &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
Image OtsuThreshold(const Image &image, const Image &maskImage, uint8_t insideValue=1u, uint8_t outsideValue=0u, uint32_t numberOfHistogramBins=128u, bool maskOutput=true, uint8_t maskValue=255u, bool returnBinMidpoint=false)
Threshold an image using the Otsu Threshold.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
Image Exp(Image &&image1)
Computes the exponential function of each pixel.
Image Shrink(const Image &image1, std::vector< unsigned int > shrinkFactors=std::vector< unsigned int >(3, 1))
Reduce the size of an image by an integer factor in each dimension.
Image Divide(Image &&image1, const Image &image2)
Pixel-wise division of two images.
SITKIO_EXPORT void WriteImage(const Image &image, const PathType &fileName, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageFileWriter. class which is convenient for many image...