|
|
|
@ -6,27 +6,30 @@ import numpy as np
|
|
|
|
|
def onselect(eclick, erelease):
|
|
|
|
|
x1, y1 = int(eclick.xdata), int(eclick.ydata)
|
|
|
|
|
x2, y2 = int(erelease.xdata), int(erelease.ydata)
|
|
|
|
|
img[y1:y2,x1:x2] = (255,0,0)
|
|
|
|
|
mask[y1:y2,x1:x2] = True
|
|
|
|
|
img[y1:y2+1,x1:x2+1] = (255,0,0)
|
|
|
|
|
mask[y1:y2+1,x1:x2+1] = True
|
|
|
|
|
maskImg[y1:y2+1,x1:x2+1] = 255
|
|
|
|
|
ax.imshow(img)
|
|
|
|
|
plt.draw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img = read(input("lien relatif de l'image: "))
|
|
|
|
|
img = img.copy()
|
|
|
|
|
imgOr = read(input("lien relatif de l'image: "))
|
|
|
|
|
img = imgOr.copy()
|
|
|
|
|
|
|
|
|
|
rep = input("avez vous le mask de l'image ?(y:n)")
|
|
|
|
|
yes = ["y","Y","yes","YES","Yes","o","O","oui","OUI"]
|
|
|
|
|
height, width = img.shape[:2]
|
|
|
|
|
if (rep in yes):
|
|
|
|
|
maskImg = read(input("lien relatife de l'image: "))
|
|
|
|
|
if (len(maskImg.shape) == 3):
|
|
|
|
|
maskImg = maskImg[:,:,0]
|
|
|
|
|
mask = maskImg == 255
|
|
|
|
|
img[mask] = (255,0,0)
|
|
|
|
|
else:
|
|
|
|
|
fig, ax = plt.subplots()
|
|
|
|
|
plt.axis("off")
|
|
|
|
|
ax.imshow(img)
|
|
|
|
|
mask = np.zeros((height, width), dtype=bool)
|
|
|
|
|
maskImg = np.zeros((height, width), dtype=np.uint8)
|
|
|
|
|
toggle_selector = RectangleSelector(ax, onselect, useblit=True,
|
|
|
|
|
button=[1], minspanx=5, minspany=5, spancoords='pixels',
|
|
|
|
|
interactive=True)
|
|
|
|
@ -42,7 +45,23 @@ plt.title("mask de l'image")
|
|
|
|
|
plt.pause(1)
|
|
|
|
|
plt.title("génération de l'image")
|
|
|
|
|
|
|
|
|
|
img = doTheInpainting(img,mask,2)
|
|
|
|
|
plt.imshow(img)
|
|
|
|
|
plt.title("image final")
|
|
|
|
|
plt.pause(20)
|
|
|
|
|
res = doTheInpainting(img,mask,2)
|
|
|
|
|
plt.ioff()
|
|
|
|
|
|
|
|
|
|
if input("afficher le résultat avant après (y/n): ") in yes:
|
|
|
|
|
fig, (ax1, ax2) = plt.subplots(1, 2)
|
|
|
|
|
ax1.imshow(imgOr)
|
|
|
|
|
ax1.set_title('Original')
|
|
|
|
|
ax1.axis("off")
|
|
|
|
|
ax2.imshow(res)
|
|
|
|
|
ax2.set_title('Result')
|
|
|
|
|
ax2.axis("off")
|
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
if input("enregister le mask (y/n):") in yes:
|
|
|
|
|
save_path = input("Entrez le chemin d'enregistrement du mask: ")
|
|
|
|
|
plt.imsave(save_path, maskImg, cmap='gray')
|
|
|
|
|
|
|
|
|
|
if input("enregister l'image produite (y/n):") in yes:
|
|
|
|
|
save_path = input("Entrez le chemin d'enregistrement de l'image: ")
|
|
|
|
|
plt.imsave(save_path, res)
|
|
|
|
|