Converting large SCN to Tiff

Viewed 91

I am having difficulty converting the .scn file found here https://drive.google.com/file/d/1JQBT-a6icoRiJ7ljSNr6_2Fi1IdOjZVZ/view?usp=sharing to a tiff and/or jpeg image format. The file is about 3GB The following is my code:

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image

slide = 'KBR-20X-S8.scn'


def get_scence_num(img_file):
    slide = slideio.open_slide(img_file, "SCN")
    return slide.num_scenes


def get_img(img_file, scene_num):
    slide = slideio.open_slide(img_file, "SCN")
    scene = slide.get_scene(scene_num)
    return scene.read_block()

print('Loading Image Data')
image = get_img(slide, 1)
print('Image data finished loading. Reshaping data')
image = image.reshape(-1,)
print('Reshaping complete. Splitting Array')
#newarr = np.array_split(image,3)
#image.save('test.tif')
print('Saving in progress')
plt.imsave('test.jpeg',image )
#plt.show()

I am getting the following errors when I try different things

numpy.core._exceptions._ArrayMemoryError: Unable to allocate 59.4 GiB for an array with shape (15949892010,) and data type float32

OverflowError: Python int too large to convert to C long

Any help will be very much appreciated.

0 Answers
Related