diff --git a/large_image/tilesource/base.py b/large_image/tilesource/base.py index 34f930cd5..290d06530 100644 --- a/large_image/tilesource/base.py +++ b/large_image/tilesource/base.py @@ -1866,11 +1866,14 @@ def getRegion(self, format=(TILE_FORMAT_IMAGE, ), **kwargs): if tiled: return self._encodeTiledImage(image, outWidth, outHeight, iterInfo, **kwargs) if outWidth != regionWidth or outHeight != regionHeight: + dtype = image.dtype image = _imageToPIL(image, mode).resize( (outWidth, outHeight), getattr(PIL.Image, 'Resampling', PIL.Image).BICUBIC if outWidth > regionWidth else getattr(PIL.Image, 'Resampling', PIL.Image).LANCZOS) + if dtype == numpy.uint16 and TILE_FORMAT_NUMPY in format: + image = _imageToNumpy(image)[0].astype(dtype) * 257 maxWidth = kwargs.get('output', {}).get('maxWidth') maxHeight = kwargs.get('output', {}).get('maxHeight') if kwargs.get('fill') and maxWidth and maxHeight: diff --git a/sources/multi/large_image_source_multi/__init__.py b/sources/multi/large_image_source_multi/__init__.py index cfb6b939b..c9cd2a4fa 100644 --- a/sources/multi/large_image_source_multi/__init__.py +++ b/sources/multi/large_image_source_multi/__init__.py @@ -100,6 +100,26 @@ 'type': 'integer', 'minimum': 0, }, + 'zSet': { + 'description': 'Override value for frame', + 'type': 'integer', + 'minimum': 0, + }, + 'tSet': { + 'description': 'Override value for frame', + 'type': 'integer', + 'minimum': 0, + }, + 'xySet': { + 'description': 'Override value for frame', + 'type': 'integer', + 'minimum': 0, + }, + 'cSet': { + 'description': 'Override value for frame', + 'type': 'integer', + 'minimum': 0, + }, 'zValues': { 'description': 'The numerical z position of the different z indices of the ' @@ -124,10 +144,10 @@ }, 'xyValues': { 'description': - 'The numerical zy position of the different zy indices of the ' + 'The numerical xy position of the different xy indices of the ' 'source. If only one value is specified, other indices are ' 'shifted based on the source. If fewer values are given than ' - 'zy indices, the last two value given imply a stride for the ' + 'xy indices, the last two value given imply a stride for the ' 'remainder.', 'type': 'array', 'items': {'type': 'number'}, @@ -533,6 +553,8 @@ def _axisKey(self, source, value, key): :param key: the axis key. One of frame, c, z, t, xy. :returns: the axis key (an integer). """ + if source.get('%sSet' % key) is not None: + return source.get('%sSet' % key) vals = source.get('%sValues' % key) or [] if not vals: axisKey = value + source.get(key, 0) @@ -868,12 +890,16 @@ def _mergeTiles(self, base, tile, x, y): base = numpy.zeros((0, 0, tile.shape[2]), dtype=tile.dtype) base, tile = _makeSameChannelDepth(base, tile) if base.shape[0] < tile.shape[0] + y: - vfill = numpy.zeros((tile.shape[0] + y - base.shape[0], base.shape[1], base.shape[2])) + vfill = numpy.zeros( + (tile.shape[0] + y - base.shape[0], base.shape[1], base.shape[2]), + dtype=base.dtype) if base.shape[2] == 2 or base.shape[2] == 4: vfill[:, :, -1] = 1 base = numpy.vstack((base, vfill)) if base.shape[1] < tile.shape[1] + x: - hfill = numpy.zeros((base.shape[0], tile.shape[1] + x - base.shape[1], base.shape[2])) + hfill = numpy.zeros( + (base.shape[0], tile.shape[1] + x - base.shape[1], base.shape[2]), + dtype=base.dtype) if base.shape[2] == 2 or base.shape[2] == 4: hfill[:, :, -1] = 1 base = numpy.hstack((base, hfill)) diff --git a/test/test_source_ometiff.py b/test/test_source_ometiff.py index a4d8ec7af..094604eeb 100644 --- a/test/test_source_ometiff.py +++ b/test/test_source_ometiff.py @@ -90,6 +90,7 @@ def testStyleAutoMinMax(): output={'maxWidth': 256, 'maxHeight': 256}, format=TILE_FORMAT_NUMPY, frame=1) imageB = imageB[:, :, :1] assert numpy.any(image != imageB) + imageB = imageB.astype(numpy.uint16) * 257 assert image.shape == imageB.shape assert image[128][128][0] < imageB[128][128][0] assert image[0][128][0] < imageB[0][128][0]