From 5868b37fb7e9505c91a33460f9f78a90d5562787 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 10 Sep 2024 19:51:14 -0400 Subject: [PATCH] Fix scaling small images in the multi source PR #1627 fixed one problem and introduced another. This fixes it. --- CHANGELOG.md | 4 ++++ .../large_image_source_multi/__init__.py | 2 +- test/test_source_multi.py | 20 +++++++++---------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa6718c2..e6645dcb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.29.9 + +- Fix scaling small images in the multi source ([#1633](../../pull/1633)) + ## 1.29.8 ### Improvements diff --git a/sources/multi/large_image_source_multi/__init__.py b/sources/multi/large_image_source_multi/__init__.py index a400d528d..199b9bb33 100644 --- a/sources/multi/large_image_source_multi/__init__.py +++ b/sources/multi/large_image_source_multi/__init__.py @@ -1119,8 +1119,8 @@ def _getTransformedTile(self, ts, transform, corners, scale, frame, crop=None): # Recompute where the source corners will land destcorners = (np.dot(transform, regioncorners.T).T).tolist() destShape = [ - max(max(math.ceil(c[0]) for c in destcorners), srcImage.shape[1]), max(max(math.ceil(c[1]) for c in destcorners), srcImage.shape[0]), + max(max(math.ceil(c[0]) for c in destcorners), srcImage.shape[1]), ] if max(0, -x) or max(0, -y): transform[0][2] -= max(0, -x) diff --git a/test/test_source_multi.py b/test/test_source_multi.py index 3bbb4b708..fbf749035 100644 --- a/test/test_source_multi.py +++ b/test/test_source_multi.py @@ -274,13 +274,13 @@ def testMultiAffineTransform(): source = large_image_source_multi.open(imagePath) frameval = [ [243, 243, 49065], - [3924, 3924, 47676], - [13, 13, 49148], - [2592, 2592, 48093], - [235, 235, 49062], - [942, 942, 48785], - [1014, 1014, 48872], - [198, 198, 49063], + [3920, 3920, 47672], + [13, 13, 49149], + [3943, 3943, 47695], + [246, 246, 49063], + [972, 972, 48785], + [1455, 1455, 48597], + [204, 204, 49059], ] for frame in range(8): thumbs = {} @@ -292,9 +292,9 @@ def testMultiAffineTransform(): r = np.sum(img[:, :, 0] >= 128) g = np.sum(img[:, :, 1] >= 128) b = np.sum(img[:, :, 2] >= 128) - assert abs(r - frameval[frame][0]) < 250 - assert abs(g - frameval[frame][1]) < 250 - assert abs(b - frameval[frame][2]) < 250 + assert abs(r - frameval[frame][0]) < 200 + assert abs(g - frameval[frame][1]) < 200 + assert abs(b - frameval[frame][2]) < 200 assert abs(np.average(thumbs[2048] - thumbs[256])) < 7 assert abs(np.average(thumbs[1024] - thumbs[256])) < 7 assert abs(np.average(thumbs[512] - thumbs[256])) < 7