|
| 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