From 5ba2ad6f7b33a346b21fe2684014df70481b7357 Mon Sep 17 00:00:00 2001 From: Pranjal Sahu Date: Fri, 20 May 2022 14:07:26 -0400 Subject: [PATCH] ENH: Adding python sample for SmoothImageWithDiscreteGaussianFilter --- .../Code.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Filtering/Smoothing/SmoothImageWithDiscreteGaussianFilter/Code.py diff --git a/src/Filtering/Smoothing/SmoothImageWithDiscreteGaussianFilter/Code.py b/src/Filtering/Smoothing/SmoothImageWithDiscreteGaussianFilter/Code.py new file mode 100644 index 000000000..93bc78d2d --- /dev/null +++ b/src/Filtering/Smoothing/SmoothImageWithDiscreteGaussianFilter/Code.py @@ -0,0 +1,30 @@ +import itk +import argparse + +parser = argparse.ArgumentParser(description="Filtering Of An Image with DiscreteGaussianFilter") +parser.add_argument("input_image") +parser.add_argument("variance", type=float) +args = parser.parse_args() + +PixelType = itk.F + +# Read Image in float data type +inputImage = itk.imread(args.input_image, PixelType) + +# Check some information from the inputImage +print('Shape ', inputImage.shape) +print('dtype is ', inputImage.dtype) +print('type is ', type(inputImage)) + +variance = args.variance +filteredImage = itk.discrete_gaussian_image_filter(inputImage, variance=variance) + +# Check some information from the filteredImage +print('Shape ', filteredImage.shape) +print('dtype is ', filteredImage.dtype) +print('type is ', type(filteredImage)) + +# Visualize the result using matplotlib +import matplotlib.pyplot as plt +plt.imshow(filteredImage) +plt.show()