python gaussian filter 1

python gaussian filter

>>> from scipy import misc
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> plt.gray()  # show the filtered result in grayscale
>>> ax1 = fig.add_subplot(121)  # left side
>>> ax2 = fig.add_subplot(122)  # right side
>>> ascent = misc.ascent()
>>> result = gaussian_filter(ascent, sigma=5)
>>> ax1.imshow(ascent)
>>> ax2.imshow(result)
>>> plt.show()

Here is what the above code is Doing:
1. We import the necessary modules.
2. We create a figure with two subplots.
3. We set the subplots to be in “gray” mode.
4. We load the ascent image from scipy.misc.
5. We apply a Gaussian filter to the ascent image.
6. We show the original image on the left.
7. We show the filtered image on the right.
8. We show the figure.

Similar Posts