Skip to content

Commit

Permalink
Merge pull request #607 from girder/optimize-tile-compositing
Browse files Browse the repository at this point in the history
Reduce time to composite styled tiles.
  • Loading branch information
manthey authored May 20, 2021
2 parents 94132df + 1a8bddd commit 1f30fc5
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions sources/nd2/large_image_source_nd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,11 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs):
x1 = min((x + 1) * step * self.tileWidth, self.sizeX)
y0 = y * step * self.tileHeight
y1 = min((y + 1) * step * self.tileHeight, self.sizeY)
if getattr(self, 'style', None) and not getattr(self, '_skipStyle', False):
with self._tileLock:
if 0 not in self._recentFrames:
self._recentFrames[0] = self._nd2[0]
tileframe = self._recentFrames[0]
tile = tileframe[0:1, 0:1].copy()
tile = numpy.zeros(
tuple([self.tileHeight, self.tileWidth] + list(tile.shape[2:])), dtype=tile.dtype)
else:
with self._tileLock:
if frame not in self._recentFrames:
self._recentFrames[frame] = self._nd2[frame]
tileframe = self._recentFrames[frame]
tile = tileframe[y0:y1:step, x0:x1:step].copy()
with self._tileLock:
if frame not in self._recentFrames:
self._recentFrames[frame] = self._nd2[frame]
tileframe = self._recentFrames[frame]
tile = tileframe[y0:y1:step, x0:x1:step].copy()
return self._outputTile(tile, TILE_FORMAT_NUMPY, x, y, z,
pilImageAllowed, numpyAllowed, **kwargs)

Expand Down

0 comments on commit 1f30fc5

Please sign in to comment.