Skip to content

Commit

Permalink
Check extended fg (#210)
Browse files Browse the repository at this point in the history
* Check extended fg

Signed-off-by: lizz <[email protected]>

* lint

Signed-off-by: lizz <[email protected]>
  • Loading branch information
innerlee authored Feb 26, 2021
1 parent 0a32934 commit 0abd0fe
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tools/data/matting/comp1k/check_extended_fg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
# This script checks the alpha-foreground difference between
# the extended fg and the original fg

import glob
import os

import cv2
import numpy as np

folder = 'data/adobe_composition-1k/Training_set/Adobe-licensed images'
imgs = [
os.path.splitext(os.path.basename(x))[0]
for x in glob.glob(f'{folder}/fg/*.jpg')
]

print('max,avg,img')
for name in imgs:
alpha = cv2.imread(f'{folder}/alpha/{name}.jpg',
cv2.IMREAD_GRAYSCALE).astype(np.float32)[...,
None] / 255
fg = cv2.imread(f'{folder}/fg/{name}.jpg').astype(np.float32)
xt = cv2.imread(f'{folder}/fg_extended/{name}.png').astype(np.float32)
diff = np.abs((fg - xt) * alpha)
print(f'{diff.max()},{diff.mean()},"{name}"', flush=True)

0 comments on commit 0abd0fe

Please sign in to comment.