is there a way to save big images as pyramidal using opencv?
I have very big images that I need to save as pyramidal, I was saving them with imwrite but then I tried to open that with openslide and it couldn’t open that, throwing error(unsupported or missing image file)
is there any possible way to do saving in opencv or should I use other libraries to save as big pyramidal image?
I’m trying to scan wsi images, is opencv right library to do scan with? I have a huge numpy array from start to reduce need to pad, because when I reach edges I have to pad it and it takes double memory at first then after pad is done it goes down to right memory usage, also I have to rotate final image before save but when I rotate with opencv it takes double memory as well, is there anything I should do to not consume this much memory?
here’s where I pad image:
if np.shape(test_matrix)[1] - (cm2 + int(y_edge_on_wsi) + y_in) <= 2000:
test_matrix = np.pad(test_matrix, ((0, 0), (0, 10000), (0, 0)),
mode='constant', constant_values=255)
if np.shape(test_matrix)[0] - (cm1 + int(x_edge_on_wsi) + x_in) <= 2000:
test_matrix = np.pad(test_matrix, ((0, 10000), (0, 0), (0, 0)), mode='constant', constant_values=255)
# Add rows or columns to The beginning of the test_matrix
if cm2 + int(y_edge_on_wsi) <= 2000:
test_matrix = np.pad(test_matrix, ((0, 0), (10000, 0), (0, 0)), mode='constant', constant_values=255)
cm2 = cm2 + 10000
if cm1 + int(x_edge_on_wsi) <= 2000:
test_matrix = np.pad(test_matrix, ((10000, 0), (0, 0), (0, 0)), mode='constant', constant_values=255)
cm1 = cm1 + 10000
and this is where I rotate image and then save:
self.image = cv2.rotate(self.image, cv2.ROTATE_90_CLOCKWISE)
cv2.imwrite(self.fullSavePathTiff, self.image)
also here is memory usage at first :
memory usage before rotate
and this is after rotate is done:
memory usage after rotate
1 Like