Skip to content

Commit

Permalink
Added nearest color mode for Fill Alpha (#1883)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Jun 20, 2023
1 parent 889d8dc commit 9d75c49
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from enum import Enum

import numpy as np
from chainner_ext import fill_alpha_extend_color, fill_alpha_fragment_blur
from chainner_ext import (
fill_alpha_extend_color,
fill_alpha_fragment_blur,
fill_alpha_nearest_color,
)

import navi
from nodes.properties.inputs import EnumInput, ImageInput
Expand All @@ -15,6 +19,7 @@
class AlphaFillMethod(Enum):
EXTEND_TEXTURE = 1
EXTEND_COLOR = 2
NEAREST_COLOR = 3


@node_group.register(
Expand Down Expand Up @@ -47,6 +52,13 @@ def fill_alpha_node(img: np.ndarray, method: AlphaFillMethod) -> np.ndarray:
img = fill_alpha_extend_color(img, threshold=0.05, iterations=100_000)
elif method == AlphaFillMethod.EXTEND_COLOR:
img = fill_alpha_extend_color(img, threshold=0.05, iterations=100_000)
elif method == AlphaFillMethod.NEAREST_COLOR:
img = fill_alpha_nearest_color(
img,
threshold=0.05,
min_radius=100_000,
anti_aliasing=True,
)
else:
assert False, f"Invalid alpha fill method {method}"

Expand Down

0 comments on commit 9d75c49

Please sign in to comment.