In [1]:
%run inpainting.ipynb
In [2]:
f=Image.open('cassat_antimask.png').convert('RGB')
f=np.array(f)
restauracao=inpaint_rgb(f,f)
disp([f,restauracao])
In [3]:
#im=Image.fromarray(f)
#im.save('slides/oquee1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/oquee2.png')
In [4]:
f=Image.open('cassat_antimask.png').convert('RGB')
f=np.array(f)
#disp([f])
In [5]:
restauracao1=inpaint_rgb(f,f,mode='heat',n=10)
restauracao2=inpaint_rgb(f,f,mode='heat',n=40)
restauracao3=inpaint_rgb(f,f,mode='heat',n=80)
disp([f,restauracao1,restauracao2,restauracao3])
In [6]:
#im=Image.fromarray(f)
#im.save('slides/calor.png')
#im=Image.fromarray(restauracao1.astype('uint8'))
#im.save('slides/calor_rest1.png')
#im=Image.fromarray(restauracao2.astype('uint8'))
#im.save('slides/calor_rest2.png')
#im=Image.fromarray(restauracao3.astype('uint8'))
#im.save('slides/calor_rest3.png')
In [7]:
f=Image.open('cassat_antimask2.png').convert('RGB')
f=np.array(f)
#disp([f])
In [8]:
difusao1=inpaint_rgb(f,f,mode='heat',n=10)
difusao2=inpaint_rgb(f,f,mode='heat',n=40)
difusao3=inpaint_rgb(f,f,mode='heat',n=80)
disp([f,difusao1,difusao2,difusao3],dpi=10)
In [9]:
#im=Image.fromarray(f)
#im.save('slides/difusao.png')
#im=Image.fromarray(difusao1.astype('uint8'))
#im.save('slides/difusao1.png')
#im=Image.fromarray(difusao2.astype('uint8'))
#im.save('slides/difusao2.png')
#im=Image.fromarray(difusao3.astype('uint8'))
#im.save('slides/difusao3.png')
In [10]:
f=Image.open('cassat_antimask.png').convert('RGB')
f=np.array(f)
#disp([f])
In [11]:
restauracao1=inpaint_rgb(f,f,mode='fast',n=10)
restauracao2=inpaint_rgb(f,f,mode='fast',n=18)
restauracao3=inpaint_rgb(f,f,mode='fast',n=30)
disp([f,restauracao1,restauracao2,restauracao3])
In [12]:
#im=Image.fromarray(f)
#im.save('slides/fast.png')
#im=Image.fromarray(restauracao1.astype('uint8'))
#im.save('slides/fast_rest1.png')
#im=Image.fromarray(restauracao2.astype('uint8'))
#im.save('slides/fast_rest2.png')
#im=Image.fromarray(restauracao3.astype('uint8'))
#im.save('slides/fast_rest3.png')
In [13]:
f=Image.open('crianca.jpeg').convert('RGB')
f=np.array(f)
antimask=Image.open('crianca_antimask.png').convert('RGB')
antimask=np.array(antimask)
#disp([f,antimask])
In [14]:
restauracao=inpaint_rgb(f,antimask,mode='fast')
disp([f,restauracao],dpi=50)
In [15]:
#im=Image.fromarray(f)
#im.save('slides/foto1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/foto2.png')
In [16]:
f=Image.open('renoir2.jpg').convert('RGB')
f=np.array(f)
antimask=Image.open('renoir2_antimask1.png').convert('RGB')
antimask=np.array(antimask)
#disp([f,antimask])
danif_mat=np.abs(f[:,:,0]-antimask[:,:,0])
T=np.ones(256)
T[0]=0
t_danif_mat=T[danif_mat.astype('uint8')]
danif=np.sum(danif_mat)/(danif_mat.shape[0]*danif_mat.shape[1])
print('imagem danificada',danif,'%')
In [17]:
restauracao=inpaint_rgb(f,antimask,mode='fast')
disp([antimask,restauracao])
err_mat=np.abs(restauracao-f)
err=np.sum(err_mat)/(err_mat.shape[0]*err_mat.shape[1])
print('erro médio por pixel: ',err)
In [18]:
#im=Image.fromarray(antimask)
#im.save('slides/texto1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/texto2.png')
In [19]:
f=Image.open('renoir2.jpg').convert('RGB')
f=np.array(f)
antimask=Image.open('renoir2_antimask2.png').convert('RGB')
antimask=np.array(antimask)
#disp([f,antimask])
danif_mat=np.abs(f[:,:,0]-antimask[:,:,0])
T=np.ones(256)
T[0]=0
t_danif_mat=T[danif_mat.astype('uint8')]
danif=np.sum(danif_mat)/(danif_mat.shape[0]*danif_mat.shape[1])
print('imagem danificada',danif,'%')
In [20]:
restauracao=inpaint_rgb(f,antimask,mode='fast')
disp([antimask,restauracao])
err_mat=np.abs(restauracao-f)
err=np.sum(err_mat)/(err_mat.shape[0]*err_mat.shape[1])
print('erro médio por pixel: ',err)
In [21]:
#im=Image.fromarray(antimask)
#im.save('slides/rabisco1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/rabisco2.png')
In [22]:
f=Image.open('renoir2.jpg').convert('RGB')
f=np.array(f)
antimask=Image.open('renoir2_antimask3.png').convert('RGB')
antimask=np.array(antimask)
#disp([f,antimask])
In [23]:
restauracao=inpaint_rgb(f,antimask,mode='fast',e=0.1)
disp([f,restauracao])
print('cabo do guarda sol removido')
In [24]:
#im=Image.fromarray(f)
#im.save('slides/objeto1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/objeto2.png')
In [25]:
f=Image.open('cassat2_antimask2.png').convert('RGB')
f=np.array(f)
In [26]:
restauracao=inpaint_rgb(f,f,mode='fast',e=1)
disp([f,restauracao])
In [27]:
#im=Image.fromarray(f)
#im.save('slides/textura1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/textura2.png')
In [28]:
f=Image.open('cassat2_antimask1.png').convert('RGB')
f=np.array(f)
In [29]:
restauracao=inpaint_rgb(f,f,mode='fast',e=1)
disp([f,restauracao])
In [30]:
#im=Image.fromarray(f)
#im.save('slides/rosto1.png')
#im=Image.fromarray(restauracao.astype('uint8'))
#im.save('slides/rosto2.png')
In [ ]: