deroneriksson / python-wsi-preprocessing Goto Github PK
View Code? Open in Web Editor NEWPython Whole Slide Image Preprocessing
Python Whole Slide Image Preprocessing
I am using this code for processing Whole Slide Images (.svs format). This code running well when NUM_TOP_TILES = 50 to NUM_TOP_TILES = 12000
. As Whole Slide Images are very large in size, in that case if I increase NUM_TOP_TILES>12000
, I'm getting OverflowError: size does not fit in an int error. This is very common issue with Pillow
when large images were used. There are many solutions are available in the github
and StackOverFlow
but I'm not able to solve my issue. As per my analysis,Image.fromarray()
of Pillow
in the below function causing this issue. It will be a great help if anyone suggest any solution to solve this issue. I have given related function
and error traceback
for your reference.
Function:
def np_to_pil(np_img):
"""
Convert a NumPy array to a PIL Image.
Args:
np_img: The image represented as a NumPy array.
Returns:
The NumPy array converted to a PIL Image.
"""
if np_img.dtype == "bool":
np_img = np_img.astype("uint8") * 255
elif np_img.dtype == "float64":
np_img = (np_img * 255).astype("uint8")
return Image.fromarray(np_img)
Error Traceback
Traceback (most recent call last):
File "WsiToImagePatch.py", line 35, in np_to_pil return Image.fromarray(np_img) File "/usr/local/lib/python3.5/dist-packages/PIL/Image.py", line 2536, in fromarray return frombuffer(mode, size, obj, "raw", rawmode, 0, 1) File "/usr/local/lib/python3.5/dist-packages/PIL/Image.py", line 2479, in frombuffer return frombytes(mode, size, data, decoder_name, args) File "/usr/local/lib/python3.5/dist-packages/PIL/Image.py", line 2412, in frombytes im.frombytes(data, decoder_name, args) File "/usr/local/lib/python3.5/dist-packages/PIL/Image.py", line 812, in frombytes s = d.decode(data) OverflowError: size does not fit in an int
Hello!
Is there any option where we can rejoin the tiled images?
I am feeding the tiled images to a CNN (input size is small) and recombine each processed tiles to original image.
I have gone through your blog and found it very useful. However I am facing issues regarding the WSI Level for Leica .scn images. Whenever i use the function slide_info() from the openslide package to get information about he dimensions, it gives incorrect information. The information doesn't seem to match the information from the image.
I am hereby attaching the details of 2 WSI and their information from the slide_info() function and from the actual WSI. The width and height at each and every level dont seem to match at all. As a result I get tiles with huge y-coordinates and few tiles are completely black. For two different WSI , openslide slide_info() function gives same level values and same dimensions which is not possible at all.
Request you to kindly inspect the issue and let me know about it, I am unable to proceed with my research. What is the workaround for such issues?
Regards,
Hitesha
nims-002.txt
nims-004.txt
In tile_extraction/filter.py, in line 286, sk_morphology.remove_small_holes
is called with the parameter name min_size
.
This probably worked for earlier versions of the sk_morphology function, but it now raises an error, as the function now expects the parameter area_threshold
, which is probably equivalent with what min_size
once meant.
-> filter.py needs to be adapted
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.