Skip to content

Commit 5ba2ad6

Browse files
committed
ENH: Adding python sample for SmoothImageWithDiscreteGaussianFilter
1 parent 6f0e16b commit 5ba2ad6

File tree

1 file changed

+30
-0
lines changed
  • src/Filtering/Smoothing/SmoothImageWithDiscreteGaussianFilter

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import itk
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description="Filtering Of An Image with DiscreteGaussianFilter")
5+
parser.add_argument("input_image")
6+
parser.add_argument("variance", type=float)
7+
args = parser.parse_args()
8+
9+
PixelType = itk.F
10+
11+
# Read Image in float data type
12+
inputImage = itk.imread(args.input_image, PixelType)
13+
14+
# Check some information from the inputImage
15+
print('Shape ', inputImage.shape)
16+
print('dtype is ', inputImage.dtype)
17+
print('type is ', type(inputImage))
18+
19+
variance = args.variance
20+
filteredImage = itk.discrete_gaussian_image_filter(inputImage, variance=variance)
21+
22+
# Check some information from the filteredImage
23+
print('Shape ', filteredImage.shape)
24+
print('dtype is ', filteredImage.dtype)
25+
print('type is ', type(filteredImage))
26+
27+
# Visualize the result using matplotlib
28+
import matplotlib.pyplot as plt
29+
plt.imshow(filteredImage)
30+
plt.show()

0 commit comments

Comments
 (0)