The mask must be 8-bit 1-channel image in function 'icvInpaint'
Code:
import numpy as np
import cv2
from PIL import Image
import base64
import io
import matplotlib.pyplot as plt
def main(data,data2):
decoded_data=base64.b64decode(data)
decoded_data2=base64.b64decode(data2)
np_data=np.fromstring(decoded_data,np.uint8)
np_data2=np.fromstring(decoded_data2,np.uint8)
img=cv2.imdecode(np_data,cv2.IMREAD_UNCHANGED)
src=cv2.imdecode(np_data2,cv2.IMREAD_UNCHANGED)
dst = cv2.inpaint(img, src, 3, cv2.INPAINT_NS)
pil_im=Image.fromarray(dst)
buff=io.BytesIO()
pil_im.save(buff,format="PNG")
img_str=base64.b64encode(buff.getvalue())
return ""+str(img_str,'utf-8')
yes. The mask must be a 8-bit 1-channel (i.e. grayscale) image. What's the problem?