I have the following code:
def click(action, x,y,flags,params):
global a, image
a = 40
if action == cv2.EVENT_LBUTTONDOWN:
patch = selectPatch(x,y)
image = clone(x,y,patch,dummy)
cv2.imshow('Image',image)
image = cv2.imread(r'...\blemish.png')
dummy = image.copy()
img = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
cv2.namedWindow('Image')
cv2.setMouseCallback('Image',click)
k= 0
while k != 27:
cv2.imshow('Image', image)
k = cv2.waitKey(20)
cv2.destroyAllWindows()
I am trying to basically make spot removal from scratch in opencv. Now this code works partially when i click on the spot it clones the best fit from neighbourhood. However when i click the second time it undoes the first fix and applies fix to the second spot only. So it basically only fixes one spot and undoes any previous ones. So in essence what i think the problem is how to store the result as the original image and then updating it each time i make a click. I am not sure how to achieve this.