Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
1498f1a3
Commit
1498f1a3
authored
Aug 17, 2023
by
comfyanonymous
Browse files
Merge branch 'add-growmask-node' of
https://github.com/coreyryanhanson/ComfyUI
parents
3aee33b5
18e86a40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
comfy_extras/nodes_mask.py
comfy_extras/nodes_mask.py
+32
-0
No files found.
comfy_extras/nodes_mask.py
View file @
1498f1a3
import
numpy
as
np
from
scipy.ndimage
import
grey_dilation
import
torch
import
torch
from
nodes
import
MAX_RESOLUTION
from
nodes
import
MAX_RESOLUTION
...
@@ -276,6 +278,35 @@ class FeatherMask:
...
@@ -276,6 +278,35 @@ class FeatherMask:
output
[
-
y
,
:]
*=
feather_rate
output
[
-
y
,
:]
*=
feather_rate
return
(
output
,)
return
(
output
,)
class
GrowMask
:
@
classmethod
def
INPUT_TYPES
(
cls
):
return
{
"required"
:
{
"mask"
:
(
"MASK"
,),
"expand"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"tapered_corners"
:
(
"BOOLEAN"
,
{
"default"
:
True
}),
},
}
CATEGORY
=
"mask"
RETURN_TYPES
=
(
"MASK"
,)
FUNCTION
=
"expand_mask"
def
expand_mask
(
self
,
mask
,
expand
,
tapered_corners
):
c
=
0
if
tapered_corners
else
1
kernel
=
np
.
array
([[
c
,
1
,
c
],
[
1
,
1
,
1
],
[
c
,
1
,
c
]])
output
=
mask
.
numpy
().
copy
()
while
expand
>
0
:
output
=
grey_dilation
(
output
,
footprint
=
kernel
)
expand
-=
1
output
=
torch
.
from_numpy
(
output
)
return
(
output
,)
...
@@ -289,6 +320,7 @@ NODE_CLASS_MAPPINGS = {
...
@@ -289,6 +320,7 @@ NODE_CLASS_MAPPINGS = {
"CropMask"
:
CropMask
,
"CropMask"
:
CropMask
,
"MaskComposite"
:
MaskComposite
,
"MaskComposite"
:
MaskComposite
,
"FeatherMask"
:
FeatherMask
,
"FeatherMask"
:
FeatherMask
,
"GrowMask"
:
GrowMask
,
}
}
NODE_DISPLAY_NAME_MAPPINGS
=
{
NODE_DISPLAY_NAME_MAPPINGS
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment