summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--opencv/code/filter.py21
-rw-r--r--opencv/images/landscape.pngbin0 -> 1354640 bytes
2 files changed, 21 insertions, 0 deletions
diff --git a/opencv/code/filter.py b/opencv/code/filter.py
new file mode 100644
index 0000000..ed80fb7
--- /dev/null
+++ b/opencv/code/filter.py
@@ -0,0 +1,21 @@
+import cv2
+import numpy as np
+from matplotlib import pyplot as plt
+from PIL import Image, ImageFilter
+img=cv2.imread("images/landscape.png")
+img1=Image.open("images/landscape.png")
+mean=cv2.blur(img,(3,3))
+median=cv2.medianBlur(img,3)
+w=cv2.filter2D(img,-1,3)
+gau=cv2.GaussianBlur(img,(3,3),0)
+minimg=np.array(img1.filter(ImageFilter.MinFilter(size=3)).convert('RGB'))
+maximg=np.array(img1.filter(ImageFilter.MaxFilter(size=3)).convert('RGB'))
+titles=["Original Image","Mean Image","Weighted Avg Image","Median Image","Min Image","Max Image"]
+images=[img,mean,median,w,minimg,maximg]
+for i in range(6):
+    plt.subplot(2,3,i+1)
+    plt.imshow(images[i][:,:,::-1])
+    plt.title(titles[i])
+    plt.xticks([])
+    plt.yticks([])
+plt.show()
\ No newline at end of file
diff --git a/opencv/images/landscape.png b/opencv/images/landscape.png
new file mode 100644
index 0000000..6614b21
--- /dev/null
+++ b/opencv/images/landscape.png
Binary files differ