我已经编写了一个代码来创建数据集中图像的二进制掩码。在这段代码中,我指定了图像中对象的边缘。从图片中可以看到,我遇到了一些问题。
1)我如何自动去除飞机的阴影?
2)去除阴影后如何用颜色填充区域? 谢谢...
import cv2
import numpy as np
from matplotlib import pyplot as plt
import argparse
import glob
def auto_canny(image, sigma=0.33):
v = np.median(image)
lower = int(max(0, (1.0 - sigma) * v))
upper = int(min(255, (1.0 + sigma) * v))
edged = cv2.Canny(image, lower, upper)
return edged
image = cv2.imread("2.png")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
auto = auto_canny(blurred)
cv2.imshow("Original", image)
cv2.imshow("Edges", np.hstack([auto]))
cv2.waitKey(0)