"vscode:/vscode.git/clone" did not exist on "6bffeb58afda577643d33c0888d8277b2724bc31"
Commit d76d71de authored by comfyanonymous's avatar comfyanonymous
Browse files

GrowMask can now be used with negative numbers to erode it.

parent d2cec6cd
import numpy as np import numpy as np
from scipy.ndimage import grey_dilation import scipy.ndimage
import torch import torch
import comfy.utils import comfy.utils
...@@ -311,7 +311,7 @@ class GrowMask: ...@@ -311,7 +311,7 @@ class GrowMask:
return { return {
"required": { "required": {
"mask": ("MASK",), "mask": ("MASK",),
"expand": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}), "expand": ("INT", {"default": 0, "min": -MAX_RESOLUTION, "max": MAX_RESOLUTION, "step": 1}),
"tapered_corners": ("BOOLEAN", {"default": True}), "tapered_corners": ("BOOLEAN", {"default": True}),
}, },
} }
...@@ -328,8 +328,11 @@ class GrowMask: ...@@ -328,8 +328,11 @@ class GrowMask:
[1, 1, 1], [1, 1, 1],
[c, 1, c]]) [c, 1, c]])
output = mask.numpy().copy() output = mask.numpy().copy()
while expand < 0:
output = scipy.ndimage.grey_erosion(output, footprint=kernel)
expand += 1
while expand > 0: while expand > 0:
output = grey_dilation(output, footprint=kernel) output = scipy.ndimage.grey_dilation(output, footprint=kernel)
expand -= 1 expand -= 1
output = torch.from_numpy(output) output = torch.from_numpy(output)
return (output,) return (output,)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment