22 import SimpleITK
as sitk
26 if len(sys.argv) != 5:
28 "Usage: prog inputFile outputFile replaceValue upperThreshold\n"
33 inputFileName = sys.argv[1]
34 outputFileName = sys.argv[2]
35 replaceValue = int(sys.argv[3])
36 upperThreshold = float(sys.argv[4])
45 boundary, [1] * image.GetDimension()
51 boundary =
sitk.Cast(boundary, image.GetPixelID())
56 image = image * ~boundary
59 image = image + (boundary * replaceValue)
61 if "SITK_NOSHOW" not in os.environ:
Image BinaryThreshold(const Image &image1, double lowerThreshold=0.0, double upperThreshold=255.0, uint8_t insideValue=1u, uint8_t outsideValue=0u)
Binarize an input image by thresholding.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
Image BinaryGrindPeak(const Image &image1, bool fullyConnected=false, double foregroundValue=1.0, double backgroundValue=0)
Remove the objects not connected to the boundary of the image.
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...
Image BinaryMorphologicalClosing(const Image &image1, std::vector< unsigned int > kernelRadius=std::vector< uint32_t >(3, 1), KernelEnum kernelType=itk::simple::sitkBall, double foregroundValue=1.0, bool safeBorder=true)
binary morphological closing of an image.
Image Cast(const Image &image, PixelIDValueEnum pixelID)