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
8ce63866
Commit
8ce63866
authored
3 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Created a test case for a real gray png image
parent
72f11925
No related branches found
No related tags found
1 merge request
!36
new image and hdf5 support
Pipeline
#60442
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/io/base/__init__.py
+7
-2
7 additions, 2 deletions
bob/io/base/__init__.py
bob/io/base/test/data/read_png_gray.png
+0
-0
0 additions, 0 deletions
bob/io/base/test/data/read_png_gray.png
bob/io/base/test/test_image_support.py
+7
-0
7 additions, 0 deletions
bob/io/base/test/test_image_support.py
with
14 additions
and
2 deletions
bob/io/base/__init__.py
+
7
−
2
View file @
8ce63866
...
...
@@ -4,7 +4,9 @@ import h5py
import
imageio
from
.utils
import
to_bob
,
to_matplotlib
,
opencvbgr_to_bob
,
bob_to_opencvbgr
,
imshow
import
logging
logger
=
logging
.
getLogger
(
__name__
)
import
os
...
...
@@ -84,6 +86,8 @@ def open_file(filename):
return
img
extension
=
os
.
path
.
splitext
(
filename
)[
1
]
# get the extension
# logger.error("############")
# logger.error(filename)
if
extension
in
hdf5_extensions
:
with
h5py
.
File
(
filename
,
"
r
"
)
as
f
:
...
...
@@ -99,8 +103,9 @@ def open_file(filename):
# PNGs have a 4th channel, which we don't want
# Alpha channels for instance have to be ignored
if
extension
.
lower
()
==
"
.png
"
:
img
=
img
[:,
:,
0
:
3
]
if
img
.
ndim
>
2
:
if
extension
.
lower
()
==
"
.png
"
:
img
=
img
[:,
:,
0
:
3
]
img
=
check_gray
(
img
)
return
img
if
img
.
ndim
==
2
else
to_bob
(
img
)
...
...
This diff is collapsed.
Click to expand it.
bob/io/base/test/data/read_png_gray.png
0 → 100755
+
0
−
0
View file @
8ce63866
3.48 MiB
This diff is collapsed.
Click to expand it.
bob/io/base/test/test_image_support.py
+
7
−
0
View file @
8ce63866
...
...
@@ -150,3 +150,10 @@ def test_image_load():
nose
.
tools
.
assert_raises
(
RuntimeError
,
lambda
x
:
load
(
os
.
path
.
splitext
(
x
)[
0
]
+
"
.unknown
"
),
full_file
)
def
test_image_exceptions
():
# This tests some image exceptions I found
# Real PNG image
transcode
(
datafile
(
"
read_png_gray.png
"
,
__name__
))
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