Comments (10)
Using pydicoms pixel_data_handlers as a fall back for transfer syntaxes that Pillow does not support sounds like a good idea. I made a quick test here . I dont have any examples of wsis with non-Pillow-supported transfer syntax, but I guess I can create some to test with.
from wsidicom.
Another issue related to this is that currently all image processing is done in Pillow. This works Ok for 8 bit color images and gray scale of higher bit depth. Looking at the dicom standard:
-JPEG Baseline is restricted to 8 bits. OK with Pillow
- JPEG Extended restricts color images to 8 bits but gray scale can have 16 bits. OK with Pillow
- JPEG Lossless allow 16 bits for color. Not OK with Pillow
- RLE allow 16 bits for color. Not OK with Pillow
- JPEG-LS allow 16 bits for color. Not OK with Pillow
- JPEG-2000 allow up to 40 bits for color. Not OK with Pillow.
I dont think >8 bit color images are common for WSI, so maybe it is not a problem to no support it. Alternatively we need to change the image processing (cropping, stitching, scaling) to be done in for example numpy.
from wsidicom.
Using pydicoms pixel_data_handlers as a fall back for transfer syntaxes that Pillow does not support sounds like a good idea. I made a quick test here . I dont have any examples of wsis with non-Pillow-supported transfer syntax, but I guess I can create some to test with.
Nice test code!
You can try the public slim examples here.
To access them, use the following arguments for the DICOMwebClient
:
client = DICOMwebClient(
'https://idc-external-006.uc.r.appspot.com/dcm4chee-arc/aets/DCM4CHEE/rs',
qido_url_prefix=None,
wado_url_prefix=None,
)
Most of those examples have their pixel data uncompressed (ExplicitVRLittleEndian
). If you call Image.open()
on these, however, Pillow won't be able to identify the format. pydicom's numpy_handler
looks at several DICOM attributes to convert this uncompressed data into a numpy array. This might mean it's good for us to rely on pydicom's pixel data handlers even for uncompressed data.
Those slim examples also have examples with different JPEG variants, including one that is JPEG-LS.
There are also some extensions to Pillow that might include handlers for things like JPEG-LS (for example here). However, I don't know how well supported they are (that JPEG-LS example hasn't been updated in over a year). I think it's nice to just rely on pydicom
to figure out these conversions for us, and stay up-to-date with dependencies!
from wsidicom.
Another issue related to this is that currently all image processing is done in Pillow. This works Ok for 8 bit color images and gray scale of higher bit depth.
I dont think >8 bit color images are common for WSI, so maybe it is not a problem to no support it. Alternatively we need to change the image processing (cropping, stitching, scaling) to be done in for example numpy.
If we switch it to use and return numpy arrays in wsidicom
, that will work fine with us for large_image! We can handle numpy arrays also.
from wsidicom.
Fixed by #126
Another issue related to this is that currently all image processing is done in Pillow. This works Ok for 8 bit color images and gray scale of higher bit depth.
I dont think >8 bit color images are common for WSI, so maybe it is not a problem to no support it. Alternatively we need to change the image processing (cropping, stitching, scaling) to be done in for example numpy.
If we switch it to use and return numpy arrays in
wsidicom
, that will work fine with us for large_image! We can handle numpy arrays also.
I will have to check what good alternatives there are for handling numpy image data, especially when it comes to scaling.
from wsidicom.
Fixed by #126
from wsidicom.
@erikogabrielsson By the way, it looks like pydicom's RLE decoder only requires numpy. Did you consider using that instead of pylibjpeg-rle
? The only problem with pylibjpeg-rle
is that it doesn't have python3.11 wheels, so we can't use it when we have python3.11. It looks like pylibjpeg-rle
hasn't been actively supported (the last update was over a year ago).
from wsidicom.
Yes one can decode RLE with only pydicom, but according to the pylibjpeg-rle
author it is significantly slower. I implemented a decoder using imagecodecs
, but imagecodecs does not yet support padded bytes as used in DICOM RLE.
But the pylibjpeg-rle
should be an optional extra? Are you unable to install wsidicom on >=3.11 even without the extra?
from wsidicom.
We can install wsidicom
for python versions 3.9 - 3.12, but we would only be able to include pylibjpeg-rle
for python versions 3.9 and 3.10. So users of our program that use Python 3.11 and 3.12 won't be able to decode RLE (unless it falls back to using the pydicom decoder for those versions).
from wsidicom.
You should be able to read RLE images using the PydicomDecoder
and the ImageCodecsRleEncoder
(we need to be able to also encode the format if scaled or cropped encoded tiles are requested). ImageCodecs
should support Python 3.11 and 3.12.
from wsidicom.
Related Issues (20)
- Add recipie for conda HOT 6
- Automatic selection of offset table type HOT 1
- Consider making a new output folder when saving HOT 1
- Slow Initialization HOT 5
- Cannot Install 0.9.0 with Python 3.11 Via Conda/Mamba HOT 4
- Support opening dicom dirs
- add_missing_levels does not recreate missing levels HOT 7
- need to read from google cloud bucket HOT 5
- Unpin Pillow HOT 1
- Support combining multiple series for DICOMweb HOT 2
- Add support for deciding DICOMweb transfer syntax HOT 12
- `file_meta` unavailable for instance from DICOMweb HOT 3
- Failed to parse LUT HOT 4
- PIL.UnidentifiedImageError: cannot identify image file HOT 1
- read_region() tile width and height appear to be reversed HOT 1
- HTTP Errors for Imaging Data Commons HOT 7
- Handle files missing extended_depth_of_field_bool HOT 4
- Unable to open dicomized data with wsidicom>=0.18.0 HOT 5
- Difference behaviour between WsiDicomFileSource and WsiDicomWebSource HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wsidicom.