The mask must be 8-bit 1-channel image in function 'icvInpaint'

asked 2020-11-11 04:15:59 -0600

haran1508 gravatar image

updated 2020-11-11 09:24:43 -0600

supra56 gravatar image

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')
edit retag flag offensive close merge delete

Comments

1

yes. The mask must be a 8-bit 1-channel (i.e. grayscale) image. What's the problem?

kbarni gravatar imagekbarni ( 2020-11-11 05:09:54 -0600 )edit