parent
f0a4185b1f
commit
afad87b5f2
2 changed files with 36 additions and 2 deletions
@ -0,0 +1,35 @@ |
||||
import numpy as np |
||||
import cv2 |
||||
from common import Sketcher |
||||
|
||||
help_message = '''USAGE: inpaint.py [<image>] |
||||
|
||||
Keys: |
||||
SPACE - update inpaint |
||||
r - restore image |
||||
ESC - exit |
||||
''' |
||||
|
||||
if __name__ == '__main__': |
||||
import sys |
||||
try: fn = sys.argv[1] |
||||
except: fn = '../cpp/fruits.jpg' |
||||
print help_message |
||||
|
||||
img = cv2.imread(fn) |
||||
img_mark = img.copy() |
||||
mark = np.zeros(img.shape[:2], np.uint8) |
||||
sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255)) |
||||
|
||||
while True: |
||||
ch = cv2.waitKey() |
||||
if ch == 27: |
||||
break |
||||
if ch == ord(' '): |
||||
res = cv2.inpaint(img_mark, mark, 3, cv2.INPAINT_TELEA) |
||||
cv2.imshow('inpaint', res) |
||||
if ch == ord('r'): |
||||
img_mark[:] = img |
||||
mark[:] = 0 |
||||
sketch.show() |
||||
|
Loading…
Reference in new issue