def __call__(image): from gamera.plugins import _string_io pixel_type = image.data.pixel_type if _modes.has_key(pixel_type): mode = _modes[pixel_type] else: raise ValueError("Only RGB and GREYSCALE Images are supported.") size = (image.ncols, image.nrows) try: return PIL.frombytes(mode, size, _string_io._to_raw_string(image)) except Exception: # for compatibility with pil 1.1.7 and earlier return PIL.fromstring(mode, size, _string_io._to_raw_string(image))
def __call__(image): from gamera.plugins import _string_io pixel_type = image.data.pixel_type shape = (image.nrows, image.ncols) typecode = _typecodes[pixel_type] if pixel_type == RGB: shape += (3,) array = n.fromstring(_string_io._to_raw_string(image), typecode) return n.resize(array, shape)
def __call__(image): from gamera.plugins import _string_io pixel_type = image.data.pixel_type if _modes.has_key(pixel_type): mode = _modes[pixel_type] else: raise ValueError("Only RGB and GREYSCALE Images are supported.") size = (image.ncols, image.nrows) return PIL.fromstring(mode, size, _string_io._to_raw_string(image))
def __call__(image): from gamera.plugins import _string_io pixel_type = image.data.pixel_type if _modes.has_key(pixel_type): mode = _modes[pixel_type] else: raise ValueError( "Only RGB and GREYSCALE Images are supported.") size = (image.ncols, image.nrows) return PIL.fromstring(mode, size, _string_io._to_raw_string(image))
def __call__(image): from gamera.plugins import _string_io pixel_type = image.data.pixel_type shape = (image.nrows, image.ncols) typecode = _typecodes[pixel_type] tmp = _string_io._to_raw_string(image) typecode.newbyteorder('>') if pixel_type == RGB: shape += (3, ) array = n.frombuffer(tmp, typecode, 3) return n.resize(array, shape)