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

Reduce memory allocation during some styling operations #1262

Merged
merged 1 commit into from
Aug 14, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Add an endpoint to make it easier to replace thumbnails ([#1253](../../pull/1253))
- Presets from Large Image Configuration file ([#1248](../../pull/1248), [#1256](../../pull/1256))
- Reduce memory allocation during some region tiling operations ([#1261](../../pull/1261))
- Reduce memory allocation during some styling operations ([#1262](../../pull/1262))

### Changes
- Minor code changes based on suggestions from ruff linting ([#1257](../../pull/1257))
Expand Down
4 changes: 3 additions & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,9 @@ def _applyStyle(self, image, style, x, y, z, frame=None): # noqa
if not style or ('icc' in style and len(style) == 1):
sc.output = image
else:
sc.output = np.zeros((image.shape[0], image.shape[1], 4), float)
sc.output = np.zeros(
(image.shape[0], image.shape[1], 4),
np.float32 if image.dtype != np.float64 else image.dtype)
image = self._applyStyleFunction(image, sc, 'pre')
for eidx, entry in enumerate(sc.style['bands']):
sc.styleIndex = eidx
Expand Down