Skip to content

Commit 41ba691

Browse files
author
Lee Kamentsky
committed
issue #25 Protect against indexed + no LUT
1 parent 1492e44 commit 41ba691

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

bioformats/formatreader.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -840,16 +840,21 @@ def read(self, c = None, z = 0, t = 0, series = None, index = None,
840840
image = np.frombuffer(self.rdr.openBytes(index),dtype)
841841
if pixel_type in (FormatTools.INT16, FormatTools.UINT16):
842842
lut = self.rdr.get16BitLookupTable()
843-
lut = np.array(
844-
[env.get_short_array_elements(d)
845-
for d in env.get_object_array_elements(lut)]).transpose()
843+
if lut is not None:
844+
lut = np.array(
845+
[env.get_short_array_elements(d)
846+
for d in env.get_object_array_elements(lut)])\
847+
.transpose()
846848
else:
847849
lut = self.rdr.get8BitLookupTable()
848-
lut = np.array(
849-
[env.get_byte_array_elements(d)
850-
for d in env.get_object_array_elements(lut)]).transpose()
850+
if lut is not None:
851+
lut = np.array(
852+
[env.get_byte_array_elements(d)
853+
for d in env.get_object_array_elements(lut)])\
854+
.transpose()
851855
image.shape = (height, width)
852-
if not np.all(lut == np.arange(lut.shape[0])[:, np.newaxis]):
856+
if (lut is not None) \
857+
and not np.all(lut == np.arange(lut.shape[0])[:, np.newaxis]):
853858
image = lut[image, :]
854859
else:
855860
index = self.rdr.getIndex(z,0,t)

0 commit comments

Comments
 (0)