Skip to content

Commit

Permalink
Improve tifffile associated image detection.
Browse files Browse the repository at this point in the history
Better detect when the tifffile source thinks there are associated
images.

Improve vips format conversion.
  • Loading branch information
manthey committed Oct 5, 2023
1 parent 23ea5c3 commit 5285e5d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Improvements
- Style can specify a dtype of 'source' to maintain the original dtype even when compositing frames ([#1326](../../pull/1326))
- Max Merge option in Frame Selector ([#1306](../../pull/1306), [#1330](../../pull/1330))
- Improve tifffile associated image detection ([#1333](../../pull/1333))

### Changes
- Prohibit bioformats and vips from reading mrxs directly ([#1328](../../pull/1328))
Expand Down
2 changes: 1 addition & 1 deletion large_image/tilesource/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _vipsCast(image, mustBe8Bit=False, originalScale=None):
if image.format not in formats or (image.format == pyvips.BandFormat.USHORT and not mustBe8Bit):
return image
target, offset, multiplier = formats[image.format]
if image.format == pyvips.BandFormat.DOUBLE:
if image.format == pyvips.BandFormat.DOUBLE or image.format == pyvips.BandFormat.FLOAT:
maxVal = image.max()
# These thresholds are higher than 256 and 65536 because bicubic and
# other interpolations can cause value spikes
Expand Down
3 changes: 2 additions & 1 deletion sources/tifffile/large_image_source_tifffile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,11 @@ def _findAssociatedImages(self):
Find associated images from unused pages and series.
"""
pagesInSeries = [p for s in self._tf.series for ll in s.pages.levels for p in ll.pages]
hashes = [p.hash for p in pagesInSeries if p.keyframe is not None]
self._associatedImages = {}
for p in self._tf.pages:
if (p not in pagesInSeries and p.keyframe is not None and
not len(set(p.axes) - set('YXS'))):
p.hash not in hashes and not len(set(p.axes) - set('YXS'))):
id = 'image_%s' % p.index
entry = {'page': p.index}
entry['width'] = p.shape[p.axes.index('X')]
Expand Down

0 comments on commit 5285e5d

Please sign in to comment.