Image processing module ndimage

an original image 

1 code
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. plt.imshow(face)#绘制测试图像
  7. plt.show()#原始图像
2 Running results


 
 
Two Gaussian filter
1 code
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. blurred_face = ndimage.gaussian_filter(face, sigma=7)#高斯滤波
  7. plt.imshow(blurred_face)
  8. plt.show()
2 Running results


 
 
Three edge sharpening
1 code
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. blurred_face1 = ndimage.gaussian_filter(face, sigma=1)#边缘锐化
  7. blurred_face3 = ndimage.gaussian_filter(face, sigma=3)
  8. sharp_face = blurred_face3 +6*(blurred_face3-blurred_face1)
  9. plt.imshow(sharp_face)
  10. plt.show()
2 Running results


 
 
Four median filter 
1 code
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. median_face = ndimage.median_filter(face,7)#中值滤波
  7. plt.imshow(median_face)
  8. plt.show()
2 Running results


 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327069094&siteId=291194637