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

Improve tifffile associated image detection. #1333

Merged
merged 1 commit into from
Oct 5, 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 @@ -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