问题描述
https://i.stack.imgur.com/u95kE.jpg
class Layer2:
@classmethod
def shadowRemoval(cls,img):
image = cv2.imread(img)
ycbcrImage = cv2.cvtColor(image,cv2.COLOR_BGR2YCrCb)
binaryMask = np.copy(ycbcrImage)
yMean = np.mean(cv2.split(ycbcrImage)[0])
yStd = np.std(cv2.split(ycbcrImage)[0])
for i in range(ycbcrImage.shape[0]):
for j in range(ycbcrImage.shape[1]):
if ycbcrImage[i,j,0] < yMean - (yStd / 3):
binaryMask[i,j] = [255,255,255]
else:
binaryMask[i,j] = [0,0]
kernel = np.ones((3,3),np.uint8)
erosion = cv2.erode(binaryMask,kernel,iterations=1)
spiLa = 0
spiS = 0
nLa = 0
nS = 0
for i in range(ycbcrImage.shape[0]):
for j in range(ycbcrImage.shape[1]):
if erosion[i,0] == 0 and erosion[i,1] == 0 and erosion[i,2] == 0:
spiLa = spiLa + ycbcrImage[i,0]
nLa += 1
else:
spiS = spiS + ycbcrImage[i,0]
nS += 1
averageLd = spiLa / nLa
averageLe = spiS / nS
iDiff = averageLd - averageLe
ratioAsAl = averageLd / averageLe
for i in range(ycbcrImage.shape[0]):
for j in range(ycbcrImage.shape[1]):
if erosion[i,0] == 255 and erosion[i,1] == 255 and erosion[i,2] == 255:
ycbcrImage[i,j] = [ycbcrImage[i,0] + iDiff,ycbcrImage[i,1] + ratioAsAl,2] + ratioAsAl]
final_image = cv2.cvtColor(ycbcrImage,cv2.COLOR_YCR_CB2BGR)
image = imutils.resize(final_image,width=1000)
cv2.imshow("img",ycbcrImage)
cv2.imwrite("img.png",image)
cv2.waitKey(0)
Layer2.shadowREmoval("image.png")
https://i.stack.imgur.com/0oIny.jpg
检测阴影区域后,结果图像已从ycbcr图像空间转换为BGR图像空间,我应该在结果图像上应用什么技术/方法以获得适当的BGR。
提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)