Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 98c81d9

Browse files
authored
Create Ghost filter code.py
1 parent e41b2c3 commit 98c81d9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎Ghost filter/Ghost filter code.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from matplotlib import pyplot as plt
2+
import numpy as np
3+
import cv2
4+
img = cv2.imread('Real Photo.jpg')
5+
#plt.imshow(img)
6+
#plt.show()
7+
image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
8+
#plt.figure(figsize= (10,10))
9+
#plt.imshow(image)
10+
#plt.show()
11+
image_small = cv2.pyrDown(img)
12+
number_iter = 5
13+
for _ in range(number_iter):
14+
image_small= cv2.bilateralFilter(image_small, d=9, sigmaColor=9, sigmaSpace=7)
15+
image_rgb = cv2.pyrUp(image_small)
16+
#plt.imshow(image_rgb)
17+
#plt.show()
18+
image_gray = cv2.cvtColor(image_rgb, cv2.COLOR_RGB2GRAY)
19+
image_blur = cv2.medianBlur(image_gray, 7)
20+
image_edge = cv2.adaptiveThreshold(image_blur, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 7, 2)
21+
#plt.imshow(image_edge)
22+
#plt.show()
23+
image_edge = cv2.cvtColor(image_edge, cv2.COLOR_GRAY2RGB)
24+
#plt.imshow(image_edge)
25+
#plt.show()
26+
# image_edge = cv2.cvtColor(image_edge, cv2.COLOR_GRAY2RGB)
27+
array = cv2.bitwise_xor(image, image_edge) #taking xor between image and image_edge to get ghost filter
28+
plt.figure(figsize= (10,10))
29+
plt.imshow(array)
30+
31+
plt.show() #real ghost filtered photo

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /