Demo entry 6780103

remove_watermark

   

Submitted by RenQJ on Dec 22, 2018 at 16:14
Language: Python 3. Code size: 1.3 kB.

def watermark(im):
    newim = im.copy()
    cim = im[min_y:min_y + height, min_x:min_x + width]
    gcim = gray(cim)
    ro = roberts(gcim)
    cv2.imshow("ro", ro)
    ret1, th1 = cv2.threshold(ro, 0, 255, cv2.THRESH_OTSU)
    cv2.imshow("th1", th1)
    dilate = cv2.dilate(th1, None, iterations=5)
    cv2.imshow('dilate', dilate)
    #mask = np.zeros((newim.shape[0], newim.shape[1]), dtype=np.uint8) * 255
    for i in range(height):
        for j in range(width):
            if dilate[i, j] == 255:
                cim[i, j] = 255
                #mask[min_y + i, min_x + j] = 255
    cv2.namedWindow('mask', 0)
    #cv2.imshow("mask", mask)
    newim[min_y:min_y + height, min_x:min_x + width] = cim
    cv2.namedWindow('white', 0)
    cv2.imshow("white", newim)
    for i in range(height):
        for j in range(width):
            if np.sum(newim[min_y + i, min_x + j]) == 255 * 3:
                newim[min_y + i, min_x + j] = predict(newim, min_y + i, min_x + j)
    cv2.namedWindow('random', 0)
    cv2.imshow("random", newim)
    blur = cv2.GaussianBlur(newim[min_y-5:min_y + height, min_x-5:min_x + width + 5], (3, 3), 0)
    newim[min_y - 5:min_y + height, min_x - 5:min_x + width + 5] = blur
    #dst = cv2.inpaint(newim, mask, 5, cv2.INPAINT_TELEA)
    return newim

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).