Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test resize using opencv native library #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/test_dataloaders.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import torchxrayvision as xrv
from skimage.io import imread, imsave

dataset_classes = [xrv.datasets.NIH_Dataset,
xrv.datasets.PC_Dataset,
Expand Down Expand Up @@ -45,3 +46,21 @@ def test_dataloader_merging_incorrect_alignment():

assert "incorrect pathology alignment" in str(excinfo.value)


def test_resize():

for filename in ["16747_3_1.jpg", "covid-19-pneumonia-58-prior.jpg"]
img = imread(filename)
img = xrv.datasets.normalize(img, 255)

# Check that images are 2D arrays
if len(img.shape) > 2:
img = img[:, :, 0]

# Add color channel
img = img[None, :, :]

resize_ski = xrv.datasets.XRayResizer(100, engine="skimage")
resize_cv2 = xrv.datasets.XRayResizer(100, engine="cv2")

assert(np.allclose(resize_ski(img),resize_cv2(img)))