Advertisement
bilelh

Batch Image filtering

May 19th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import os,glob
  2. import cv2
  3. j=0;
  4. for file in glob.glob("*.jpg"):
  5.     im = cv2.imread(file)
  6.     #dst = cv2.GaussianBlur(im,(5,5),cv2.BORDER_DEFAULT)
  7.     dst = cv2.blur(im, (5, 5), anchor=(-1, -1), borderType=cv2.BORDER_DEFAULT)
  8.     cv2.imwrite('blur-{0}.jpg'.format(j), dst)
  9.     j += 1;
  10.    
  11. ###Using Matplotlib
  12.  
  13. import os,glob
  14. import cv2
  15. from matplotlib import pyplot as plt
  16. j=0;
  17. for file in glob.glob("*.jpg"):
  18.     im = cv2.imread(file)
  19.     #dst = cv2.GaussianBlur(im,(5,5),cv2.BORDER_DEFAULT)
  20.     dst = cv2.blur(im, (5, 5), anchor=(-1, -1), borderType=cv2.BORDER_DEFAULT)
  21.     #cv2.imwrite('blur-{0}.jpg'.format(j), dst)
  22.     plt.imshow(dst)
  23.     plt.axis('off')
  24.     plt.savefig('blur-{0}.jpg'.format(j), bbox_inches='tight', transparent=True, pad_inches=0,dpi=300)
  25.     j += 1;
  26.     #plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement