I am having a tiff slide with the dimension of 90112 x 100352. The slide size is 1.3GB . To process this slide i am creating a numpy memmap file with above dimension like below.
If I check the size of the "test.memmap", its showing nearly 27GB. I dont know why its this much bigger than original tiff file.
I am reading the original slide patch by patch and copying its RGB values with "memMapRef". After reading whole slide i am drawing a rectangle on "memMapRef" at some X,Y coordinates. After drawing the rectangle, now I am trying to create image using below code from "memMapRef" numpy array. Here i am getting the Error "size does not fit in an int".
I am using the "imsave" method from scipy.misc.
My Entire code is below:
import cv2 import numpy as np from scipy.misc import imread, imresize, imsave import openslide level = 0 read_size = (10000, 10000) # reading size per patch tumor_file = "Test_Tumor.tif" # 1.3 GB file tumor_slide = openslide.open_slide(tumor_file) max_OX,max_OY = tumor_slide.level_dimensions[level] # max_OX = 90112 max_OY = 100352 memMapRef = np.memmap('test.memmap', dtype='uint8', mode='w+', shape=(max_OY,max_OX,3)) def process_slide(): for start_OX in xrange(0,max_OX,read_size): for start_OY in xrange(0,max_OY,read_size): size_OX=min(read_size,max_OX-start_OX) size_OY=min(read_size,max_OY-start_OY) tile = np.array(tumor_slide.read_region((start_OX,start_OY),level,(size_OX,size_OY)), dtype="uint8")[:,:,:3] yield tile, start_OX, start_OY for img_tile, X, Y in process_slide(): h,w,d = img_tile.shape memMapRef[Y: Y+h, X: X+w] = img_tile x1 = 500 y1 = 1000 x2 = x1+256 y2 = y1+256 cv2.rectangle(memMapRef,(x1,y1),(x2,y2),(0,255,0),10) imsave("output.png", memMapRef) # Error "size does not fit in an int".
Where I did mistake and How to fix it?