Skip to content

Commit

Permalink
Merge pull request #875 from girder/get-pixel-single-channel
Browse files Browse the repository at this point in the history
Fix getPixel for single channel sources.
  • Loading branch information
manthey authored Jun 16, 2022
2 parents c805a26 + fd9189e commit 7144a9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## Unreleased

### Bug Fixes
- Fix getPixel for single channel sources ([875](../../pull/875))

## 1.14.5

### Improvements
Expand Down
5 changes: 4 additions & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,10 @@ def getPixel(self, includeTileRecord=False, **kwargs):
pixel['tile'] = tile
img = tile['tile']
if img.size[0] >= 1 and img.size[1] >= 1:
pixel.update(dict(zip(img.mode.lower(), img.load()[0, 0])))
if len(img.mode) > 1:
pixel.update(dict(zip(img.mode.lower(), img.load()[0, 0])))
else:
pixel.update(dict(zip([img.mode.lower()], [img.load()[0, 0]])))
return pixel


Expand Down
1 change: 1 addition & 0 deletions test/test_source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def testSourcesTilesAndMethods(source, filename):
assert ts.getInternalMetadata() is not None
assert ts.getOneBandInformation(1) is not None
assert len(ts.getBandInformation()) >= 1
assert ts.getPixel(region=dict(left=0, top=0)) is not None
# Histograms are too slow to test in this way
# assert len(ts.histogram()['histogram']) >= 1
# assert ts.histogram(onlyMinMax=True)['min'][0] is not None
Expand Down

0 comments on commit 7144a9b

Please sign in to comment.