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

Fix an issue in PR #1447. #1449

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 10 additions & 5 deletions sources/multi/large_image_source_multi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down