|
|
|
@ -79,16 +79,19 @@ def doPatchMatch(img,x1,y1,x2,y2,patchSize=17,nbRadomPatch=10):
|
|
|
|
|
|
|
|
|
|
ogDist = dists[minIdx]
|
|
|
|
|
foundNew = True
|
|
|
|
|
step = patchSize*5
|
|
|
|
|
step = 5
|
|
|
|
|
addr = addr[0]
|
|
|
|
|
while foundNew:
|
|
|
|
|
foundNew, tpatch, tpatchValue, tdist = getBestNeigbourPatch(addr[0],ogValue,ogDist,step)
|
|
|
|
|
foundNew, tpatch, tpatchValue, tdist = getBestNeigbourPatch(addr,ogValue,ogDist,step)
|
|
|
|
|
if (foundNew):
|
|
|
|
|
addr = tpatch[patchSize//2]
|
|
|
|
|
patch = tpatch
|
|
|
|
|
patchValue = tpatchValue
|
|
|
|
|
ogDist = tdist
|
|
|
|
|
step = 5
|
|
|
|
|
else:
|
|
|
|
|
step = int(step/2)
|
|
|
|
|
foundNew = step > 0
|
|
|
|
|
step = step*1.25
|
|
|
|
|
foundNew = step < min(width, height)/2
|
|
|
|
|
return patch, patchValue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -182,11 +185,6 @@ def doPatchMatch(img,x1,y1,x2,y2,patchSize=17,nbRadomPatch=10):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img = plt.imread('boat.png')
|
|
|
|
|
|
|
|
|
|
if len(img.shape) == 2:
|
|
|
|
@ -198,7 +196,7 @@ def onselect(eclick, erelease):
|
|
|
|
|
|
|
|
|
|
print("drawing")
|
|
|
|
|
img_copy = np.copy(img)
|
|
|
|
|
res = doPatchMatch(img_copy,int(x1),int(y1),int(x2),int(y2))
|
|
|
|
|
res = doPatchMatch(img_copy,int(x1),int(y1),int(x2),int(y2),33)
|
|
|
|
|
ax.imshow(res)
|
|
|
|
|
plt.draw()
|
|
|
|
|
print("drawed")
|
|
|
|
|