def write(fname, data_image): """ Write compressed image data to JPEG-LS file. """ data_buffer = _CharLS.encode(data_image) with open(fname, "wb") as fo: fo.write(data_buffer.tostring())
def write(fname, data_image): """ Write compressed image data to JPEG-LS file. """ data_buffer = _CharLS.encode(data_image) with open(fname, 'wb') as fo: fo.write(data_buffer.tostring())
def encode(data_image): """ Encode grey-scale image via JPEG-LS using CharLS implementation. """ if data_image.dtype == np.uint16 and np.max(data_image) <= 255: data_image = data_image.astype(np.uint8) data_buffer = _CharLS.encode(data_image) return data_buffer