-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlarge_image_gate.py
More file actions
29 lines (22 loc) · 894 Bytes
/
large_image_gate.py
File metadata and controls
29 lines (22 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#OpenSlide used to open MRXS file and keep pixel quality
#Can run only on Linux OpenSlide not in Windows
import os
import numpy as np
import matplotlib.pyplot as plt
from openslide import OpenSlide
import cv2 as cv
import glob
file_to_process = glob.glob("/home/elwin/BGSA/*.mrxs")
for datas in file_to_process :
line = datas.split("/")
line_in_array = line[-1].split(".")
title = line_in_array[0]
mrx_image = OpenSlide(datas)
gate = mrx_image.read_region((0,0),4,mrx_image.level_dimensions[4])
##read_region is used to get the level 4 of the pyramidal picture ; level 1 to 3 can't
##be used because the size and the quality of picture is too important for next step
##PIL can't open too big file
array_gate = np.array(gate)
gate_bgr = cv.cvtColor(array_gate, cv.COLOR_RGBA2BGR)
print "GATE IMAGE READ REGION : " + str(type(gate))
cv.imwrite(str(title)+ ".bmp",gate_bgr)