Skip to content

Commit

Permalink
Better computed alpha (#1942)
Browse files Browse the repository at this point in the history
* Better computed alpha

* Ignore type error

* comment
  • Loading branch information
RunDevelopment committed Jul 16, 2023
1 parent 5a45dba commit f6316f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/src/nodes/impl/upscale/convenient_upscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ def convenient_upscale(
upscale(as_target_channels(white, model_in_nc, True)), 3, True
)

alpha = 1 - np.mean(white_up - black_up, axis=2) # type: ignore
# Interpolate between the alpha values to get a more defined alpha
alpha_candidates = 1 - (white_up - black_up) # type: ignore
alpha_min = np.min(alpha_candidates, axis=2)
alpha_max = np.max(alpha_candidates, axis=2)
alpha_mean = np.mean(alpha_candidates, axis=2)
alpha = alpha_max * alpha_mean + alpha_min * (1 - alpha_mean)

return np.dstack((black_up, alpha))

return as_target_channels(
Expand Down

0 comments on commit f6316f6

Please sign in to comment.