Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
deepdraw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
medai
software
deepdraw
Commits
27212d1f
Commit
27212d1f
authored
4 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[data.utils] Add support to input user label maps and other image mode types
parent
82d085de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
Streamlining
Pipeline
#39080
failed
4 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/ip/binseg/data/utils.py
+15
-13
15 additions, 13 deletions
bob/ip/binseg/data/utils.py
with
15 additions
and
13 deletions
bob/ip/binseg/data/utils.py
+
15
−
13
View file @
27212d1f
...
@@ -54,9 +54,9 @@ def overlayed_image(
...
@@ -54,9 +54,9 @@ def overlayed_image(
An RGB PIL image that represents the original image for analysis
An RGB PIL image that represents the original image for analysis
label : PIL.Image.Image
label : PIL.Image.Image
A PIL image in mode
"
1
"
or
"
L
"
that represents the labelled elements in
A PIL image in
any
mode that represents the labelled elements in
the
the image. White pixels represent the labelled object. Black pixels
image. In case of images in mode
"
L
"
or
"
1
"
, white pixels represent
represent background.
the labelled object. Black-er pixels
represent background.
mask : py:class:`PIL.Image.Image`, Optional
mask : py:class:`PIL.Image.Image`, Optional
A PIL image in mode
"
1
"
that represents the mask for the image. White
A PIL image in mode
"
1
"
that represents the mask for the image. White
...
@@ -65,7 +65,7 @@ def overlayed_image(
...
@@ -65,7 +65,7 @@ def overlayed_image(
label_color : py:class:`tuple`, Optional
label_color : py:class:`tuple`, Optional
A tuple with three integer entries indicating the RGB color to be used
A tuple with three integer entries indicating the RGB color to be used
for labels
for labels
. Only used if ``label.mode`` is
"
1
"
or
"
L
"
.
mask_color : py:class:`tuple`, Optional
mask_color : py:class:`tuple`, Optional
A tuple with three integer entries indicating the RGB color to be used
A tuple with three integer entries indicating the RGB color to be used
...
@@ -86,21 +86,23 @@ def overlayed_image(
...
@@ -86,21 +86,23 @@ def overlayed_image(
"""
"""
# creates a representation of labels with the right color
# creates a representation of labels, in RGB format, with the right color
label_colored
=
PIL
.
ImageOps
.
colorize
(
if
label
.
mode
in
(
"
1
"
,
"
L
"
):
label
.
convert
(
"
L
"
),
(
0
,
0
,
0
),
label_color
label_colored
=
PIL
.
ImageOps
.
colorize
(
)
label
.
convert
(
"
L
"
),
(
0
,
0
,
0
),
label_color
)
else
:
# user has already passed an RGB version of the labels, just compose
label_colored
=
label
# blend image and label together - first blend to get vessels drawn with a
# blend image and label together - first blend to get vessels drawn with a
# slight "label_color" tone on top, then composite with original image,
no
t
# slight "label_color" tone on top, then composite with original image, t
o
#
to
loos
e
brightness.
#
avoid
loos
ing
brightness.
retval
=
PIL
.
Image
.
blend
(
img
,
label_colored
,
alpha
)
retval
=
PIL
.
Image
.
blend
(
img
,
label_colored
,
alpha
)
if
label
.
mode
==
"
1
"
:
if
label
.
mode
==
"
1
"
:
composite_mask
=
invert_mode1_image
(
label
)
composite_mask
=
invert_mode1_image
(
label
)
elif
label
.
mode
==
"
L
"
:
composite_mask
=
PIL
.
ImageOps
.
invert
(
label
)
else
:
else
:
raise
TypeError
(
f
"
Label image mode
{
label
.
mode
}
!= (
'
1
'
,
'
L
'
)
"
)
composite_mask
=
PIL
.
ImageOps
.
invert
(
label
.
convert
(
"
L
"
)
)
retval
=
PIL
.
Image
.
composite
(
img
,
retval
,
composite_mask
)
retval
=
PIL
.
Image
.
composite
(
img
,
retval
,
composite_mask
)
# creates a representation of the mask negative with the right color
# creates a representation of the mask negative with the right color
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment