-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Check extended fg Signed-off-by: lizz <[email protected]> * lint Signed-off-by: lizz <[email protected]>
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |