I am working on removing the company logo background image mask but I'm not getting the exact output. I try many ways to remove the company logo background but every model is trained in human categories just like model name mode net, u2net, etc. I plan to train the custom model so I need an image and mask I'm generating an image mask but not getting exact output here is my code.
import numpy as np
# Reading image
image = cv2.imread('image_path')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Find Canny edges
edged = cv2.Canny(gray, 30, 200)
cv2.waitKey(0)
# creating canvas
canvas = np.zeros(image.shape, np.uint8)
canvas.fill(255)
#creating image background mask
mask = np.ones(image.shape, dtype=np.uint8) * 255
contours, hierarchy = cv2.findContours(edged,
cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cnts = contours[0]
for c in cnts:
x,y,w,h = cv2.boundingRect(c)
ROI = image[y:y+h, x:x+w]
#finding controus
contours_mask, hierarchy = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
for contour in range(len(contours_mask)):
cv2.fillConvexPoly(mask, contours_mask[contour], (0,0,255))
# fill color in background image
cv2.floodFill(mask, None, seedPoint=(0, 0), newVal=128, loDiff=1, upDiff=1)
r=cv2.selectROI('ROI', edged,False,False)
imROI = edged[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]
cv2.imshow('Canny Edges After Contouring', ROI)
cv2.waitKey(0)
print("Number of Contours found = " + str(len(contours)))
# Draw all contours
# -1 signifies drawing all contours
cv2.drawContours(image, contours, -1, (0, 255, 0), 3)
cv2.imshow('Contours', image)
cv2.imshow('background mask', mask)
cv2.imshow('canvas', canvas)
cv2.waitKey(0)
cv2.destroyAllWindows()```
**>I am getting that kind of output in background mask image output.**
[enter image description here][1]
[enter image description here][2]
[1]: https://i.stack.imgur.com/6B5Mx.png

