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
d76d71de
Commit
d76d71de
authored
Sep 26, 2023
by
comfyanonymous
Browse files
GrowMask can now be used with negative numbers to erode it.
parent
d2cec6cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
comfy_extras/nodes_mask.py
comfy_extras/nodes_mask.py
+6
-3
No files found.
comfy_extras/nodes_mask.py
View file @
d76d71de
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
,)
...
...
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