20 from __future__
import print_function
22 import SimpleITK
as sitk
27 print(
"Usage: N4BiasFieldCorrection inputImage " +
28 "outputImage [shrinkFactor] [maskImage] [numberOfIterations] " +
29 "[numberOfFittingLevels]")
41 [int(sys.argv[3])] * inputImage.GetDimension())
43 [int(sys.argv[3])] * inputImage.GetDimension())
45 inputImage =
sitk.Cast(inputImage, sitk.sitkFloat32)
49 numberFittingLevels = 4
52 numberFittingLevels = int(sys.argv[6])
55 corrector.SetMaximumNumberOfIterations([int(sys.argv[5])]
56 * numberFittingLevels)
58 output = corrector.Execute(inputImage, maskImage)
62 if (
"SITK_NOSHOW" not in os.environ):
Image OtsuThreshold(const Image &image, 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.
SITKIO_EXPORT void WriteImage(const Image &image, const std::vector< std::string > &fileNames, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageSeriesWriter. class which is convenient for many ima...
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
SITKIO_EXPORT Image ReadImage(const std::vector< std::string > &fileNames, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image...
Implementation of the N4 bias field correction algorithm.
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 Cast(const Image &image, PixelIDValueEnum pixelID)