Skip to content
Snippets Groups Projects
Commit 8ce63866 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Created a test case for a real gray png image

parent 72f11925
No related branches found
No related tags found
1 merge request!36new image and hdf5 support
Pipeline #60442 passed
......@@ -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)
......
bob/io/base/test/data/read_png_gray.png

3.48 MiB

......@@ -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__))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment