Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
kyurkov
Opencvnodesclone
Commits
bc906d82
Commit
bc906d82
authored
1 year ago
by
kyurkov
Browse files
Options
Download
Email Patches
Plain Diff
added extend mask
parent
240209bc
main
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MaskNodes.py
+41
-0
MaskNodes.py
with
41 additions
and
0 deletions
+41
-0
MaskNodes.py
+
41
-
0
View file @
bc906d82
...
...
@@ -1002,6 +1002,45 @@ class ChangeChannelCount:
else
:
# RGB
return
(
tensor2rgb
(
image
),)
class
ExtendMask
:
def
__init__
(
self
):
pass
@
classmethod
def
INPUT_TYPES
(
cls
):
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
},
}
RETURN_TYPES
=
(
"IMAGE"
,)
FUNCTION
=
"extend_mask"
CATEGORY
=
"Masquerade Nodes"
def
extend_mask
(
self
,
image
):
mask
=
tensor2mask
(
image
)
morphed_white_pixels
=
torch
.
argwhere
(
mask
>
0
)
print
(
morphed_white_pixels
.
shape
)
min_y
=
min
(
morphed_white_pixels
[:,
1
])
max_y
=
max
(
morphed_white_pixels
[:,
1
])
min_x
=
min
(
morphed_white_pixels
[:,
2
])
max_x
=
max
(
morphed_white_pixels
[:,
2
])
size
=
mask
.
size
()
image_width
=
size
[
2
]
image_height
=
size
[
1
]
mask
=
torch
.
zeros
((
image_height
,
image_width
))
mask
[
int
(
max_y
):
int
(
image_height
),
int
(
min_x
):
int
(
max_x
)
+
1
]
=
1
return
(
mask
.
unsqueeze
(
0
),)
class
ConstantMask
:
def
__init__
(
self
):
pass
...
...
@@ -1313,6 +1352,7 @@ NODE_CLASS_MAPPINGS = {
"Create QR Code"
:
CreateQRCodeNode
,
"Convert Color Space"
:
ConvertColorSpace
,
"MasqueradeIncrementer"
:
MaqueradeIncrementerNode
,
"Extend mask"
:
ExtendMask
}
NODE_DISPLAY_NAME_MAPPINGS
=
{
...
...
@@ -1338,4 +1378,5 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"Create QR Code"
:
"Create QR Code"
,
"Convert Color Space"
:
"Convert Color Space"
,
"MasqueradeIncrementer"
:
"Incrementer"
,
"Extend mask"
:
"Extend mask"
,
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets