Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.base
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
bob
bob.io.base
Commits
11a70614
Commit
11a70614
authored
2 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Fix bob_to_pillow float image conversion
parent
b90e7a0d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
Tests extensions against lower case versions
Pipeline
#61341
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/io/image.py
+6
-4
6 additions, 4 deletions
bob/io/image.py
with
6 additions
and
4 deletions
bob/io/image.py
+
6
−
4
View file @
11a70614
...
...
@@ -64,8 +64,10 @@ def bob_to_pillow(img):
img
=
to_matplotlib
(
img
)
# if img is floating point, convert to uint8
if
isinstance
(
img
,
np
.
floating
):
# we expect float images to be between 0 and 1
img
=
np
.
clip
(
img
,
0
,
1
)
*
255
# In Bob, we expect float images to be between 0 and 255
# see https://gitlab.idiap.ch/bob/bob.bio.face/-/issues/48
img
=
np
.
round
(
img
)
img
=
np
.
clip
(
img
,
0
,
255
)
img
=
img
.
astype
(
np
.
uint8
)
return
Image
.
fromarray
(
img
)
...
...
@@ -108,7 +110,7 @@ def opencvbgr_to_bob(img):
If the image dimension is less than 3.
"""
if
img
.
ndim
<
3
:
r
aise
ValueError
(
"
You need to provide at least a 3 dimensional image
"
)
r
eturn
img
img
=
img
[...,
::
-
1
]
return
to_bob
(
img
)
...
...
@@ -134,7 +136,7 @@ def bob_to_opencvbgr(img):
If the image dimension is less than 3.
"""
if
img
.
ndim
<
3
:
r
aise
ValueError
(
"
You need to provide at least a 3 dimensional image
"
)
r
eturn
img
img
=
img
[...,
::
-
1
,
:,
:]
return
to_matplotlib
(
img
)
...
...
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