From 3ec732306ae563fbbb52c75a735445096be43b4f Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 30 Jan 2024 16:14:04 -0500 Subject: [PATCH] Fix an issue in PR #1447. One of the checks was disabled. --- CHANGELOG.md | 2 +- .../multi/large_image_source_multi/__init__.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e35ec62..95d831ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Improvements - Support range requests when downloading DICOMweb files ([#1444](../../pull/1444)) -- Bypass some scaling code when compositing multi sources ([#1447](../../pull/1447)) +- Bypass some scaling code when compositing multi sources ([#1447](../../pull/1447), [#1449](../../pull/1449)) ## 1.27.1 diff --git a/sources/multi/large_image_source_multi/__init__.py b/sources/multi/large_image_source_multi/__init__.py index 06478ae47..45b4527d1 100644 --- a/sources/multi/large_image_source_multi/__init__.py +++ b/sources/multi/large_image_source_multi/__init__.py @@ -934,19 +934,19 @@ def _mergeTiles(self, base, tile, x, y): vfill = np.zeros( (tile.shape[0] + y - base.shape[0], base.shape[1], base.shape[2]), dtype=base.dtype) - if base.shape[2] == 2 or base.shape[2] == 4: + if base.shape[2] in {2, 4}: vfill[:, :, -1] = fullAlphaValue(base) base = np.vstack((base, vfill)) if base.shape[1] < tile.shape[1] + x: hfill = np.zeros( (base.shape[0], tile.shape[1] + x - base.shape[1], base.shape[2]), dtype=base.dtype) - if base.shape[2] == 2 or base.shape[2] == 4: + if base.shape[2] in {2, 4}: hfill[:, :, -1] = fullAlphaValue(base) base = np.hstack((base, hfill)) if base.flags.writeable is False: base = base.copy() - if base.shape[2] == 2 or base.shape[2] == 4: + if base.shape[2] in {2, 4}: baseA = base[y:y + tile.shape[0], x:x + tile.shape[1], -1].astype( float) / fullAlphaValue(base) tileA = tile[:, :, -1].astype(float) / fullAlphaValue(tile) @@ -1112,8 +1112,8 @@ def _addSourceToTile(self, tile, sourceEntry, corners, scale): transform[0][0] > 0 and transform[0][1] == 0 and transform[1][0] == 0 and transform[1][1] > 0 and transform[0][2] % scaleX == 0 and transform[1][2] % scaleY == 0)) and - ((scaleX % scale) == 0 or math.log(scaleX, 2).is_integer) and - ((scaleY % scale) == 0 or math.log(scaleY, 2).is_integer)) and False: + ((scaleX % scale) == 0 or math.log(scaleX, 2).is_integer()) and + ((scaleY % scale) == 0 or math.log(scaleY, 2).is_integer())): srccorners = ( list(np.dot(bbox['inverse'], np.array(corners).T).T) if transform is not None else corners) @@ -1206,8 +1206,13 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs): tile = np.full((self.tileHeight, self.tileWidth, len(colors)), colors, dtype=getattr(self, '_firstdtype', np.uint8)) + # colors = self._info.get('backgroundColor') if self._info.get('singleBand'): tile = tile[:, :, 0] + # elif tile.shape[2] in {2, 4} and (colors is None or len(colors) < tile.shape[2]): + # # remove a needless alpha channel + # if np.all(tile[:, :, -1] == fullAlphaValue(tile)): + # tile = tile[:, :, :-1] # We should always have a tile return self._outputTile(tile, TILE_FORMAT_NUMPY, x, y, z, pilImageAllowed, numpyAllowed, **kwargs)