Convert image array to original svs format

2019-08-17 14:56发布

I'm trying to apply a foreground extraction to a SVS image (Whole Slide Image) usign OpenSlide library.

First, I converted my image to an array to work on my foreground extraction:

image = np.asarray(oslIm.read_region((0, 0), level, oslIm.level_dimensions[level]), dtype=np.uint8)[:, :, 0:3]

After that I generated my mask, which I applied to my converted image:

plt.imshow(image * final_mask[:, :, np.newaxis])
plt.xticks([])
plt.yticks([])
plt.savefig("./masks/ResultingImage.png", format='png', dpi=90, pad_inches=0.1, bbox_inches='tight');
plt.close()

What I want is to convert my image to svs again so I can work on the foreground of the original image and apply my patch extractor (tile the image in patches for annotation ease)

def sample_and_store_patches_by_row(
        file_name,
        pixel_overlap,
        patch_size=512,
        level=17,
):

How can I do that?

Regards

0条回答
登录 后发表回答