Comments (10)
Correction: I had not seen how to install the jpeg plugin, am trying that now. Will close if that fixes!
from pylibjpeg.
Closing, that fixed it. Thank you.
from pylibjpeg.
Actually, although I do get a pixel array without errors, now, when I try to write the image it still has mostly green in it. Please advise?
from pylibjpeg.
from pylibjpeg.
Ok more info: I tried forcing this to be interpeted by PIL as RGB and then I can write this out to look correct. My code was assuming however that this should be written out as "YCbCr" since the Photometric Interpretation is YBR_FULL_422. Should I be checking other DICOM attributes to determine whether or not to use "YCbCr"?
from pylibjpeg.
Correct image attached forcing RGB image mode when writing out.
from pylibjpeg.
pydicom returns the Pixel Data as-is, so if the Photometric Interpretation is YBR_FULL_422
then you get back a YCbCr image, if it's RGB
you get back an RGB image. To convert to RGB you can use the pydicom.pixel_data_handlers.util.convert_color_space() function.
from pylibjpeg.
Ah, I misunderstood. It should be displayed as YCbCr but its coming back as RGB.
Let me take a look
from pylibjpeg.
OK, looking at the data inside the JPG file, the SOF0
marker has three components with the component IDs: 'R', 'G', and 'B'. This is pretty standard when data has been encoded in the RGB colourspace rather than YCbCr, particularly images from Adobe like this one. I think in this case the Photometric Interpretation should be 'RGB'.
A quick googling shows this page has a bit more info.
from pylibjpeg.
For reference, heres the JPEG info:
=================== SOI marker at offset 0 ====================
------------- APP14 marker at offset 2, length 16 -------------
Adobe v100:
64 00 00 00 00 00
------------- DQT marker at offset 18, length 69 --------------
Table destination ID: 0
Table precision: 0 (8-bit)
Quantization table:
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
------------- SOF0 marker at offset 87, length 19 -------------
Baseline sequential DCT
Sample size (px): 800 x 600
Sample precision (bits): 8
Number of component images: 3
Component ID: R
Horizontal sampling factor: 1
Vertical sampling factor: 1
Quantization table destination: 0
Component ID: G
Horizontal sampling factor: 1
Vertical sampling factor: 1
Quantization table destination: 0
Component ID: B
Horizontal sampling factor: 1
Vertical sampling factor: 1
Quantization table destination: 0
------------- DHT marker at offset 106, length 33 -------------
Lossless/DC Huffman, table ID: 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
01 00 01 04 03 01 01 01 00 00 00 00 00 00 00 00 : # codes
00 : L = 1
06 : L = 3
04 05 07 08 : L = 4
02 03 09 : L = 5
0a : L = 6
01 : L = 7
0b : L = 8
------------ DHT marker at offset 139, length 112 -------------
AC Huffman, table ID: 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
00 01 03 03 03 02 03 04 04 08 0a 08 03 00 00 27 : # codes
01 : L = 2
02 03 04 : L = 3
05 06 11 : L = 4
00 07 12 : L = 5
08 21 : L = 6
13 14 31 : L = 7
09 15 22 41 : L = 8
32 51 52 61 : L = 9
16 23 54 91 92 a1 a2 d1 : L = 10
17 18 33 42 62 97 a3 d3 d6 e1 : L = 11
0a 24 57 71 93 98 d2 d7 : L = 12
43 53 81 : L = 13
19 25 56 72 34 55 82 b2 c1 f0 26 27 58 59 73 75 : L = 16
83 63 66 b1 35 36 39 44 64 c2 c3 c4 1a 28 37 38 : L = 16
74 76 88 b4 b6 b7 b8 : L = 16
------------- SOS marker at offset 251, length 14 -------------
Number of image components: 3
Component: R, DC table: 0, AC table: 0
Component: G, DC table: 0, AC table: 0
Component: B, DC table: 0, AC table: 0
Spectral selectors start-end: 0-63
Successive approximation bit high-low: 0-0
................... ENC marker at offset 263...................
399085 bytes of entropy-coded data
from pylibjpeg.
Related Issues (20)
- Change pixel data decoding interface to pass group 0028 elements
- Add documentation that defines the plugin interface
- v1.3.0 Release HOT 3
- Pixel handler with support for JPEG2000 HOT 5
- Add version awareness to plugins
- [DCM] Convert output J2K data to match Pixel Representation when required
- using pylibjpeg with executable creator libraries HOT 7
- failure in pixel_data_handlers\pylibjpeg_handler HOT 2
- JPEG encoding HOT 6
- RuntimeError: Unable to convert the Pixel Data as the 'pylibjpeg-libjpeg' plugin is not installed HOT 19
- Conda install support? HOT 5
- `RuntimeError: Unable to convert the Pixel Data as the 'pylibjpeg-libjpeg' plugin is not installed` when running the executable generated with PyInstaller (but not with the script.py) HOT 2
- Dependency on pylibjpeg-rle
- Circular import error HOT 3
- Unable to convert the Pixel Data as the 'pylibjpeg-libjpeg' plugin is not installed
- RuntimeError: Unable to convert the Pixel Data as the 'pylibjpeg-libjpeg' plugin is not installed when running the executable generated with PyInstaller (but not with the script.py)
- Libjpeg-turbo HOT 8
- Use importlib rather than pkg_resources
- DICOM compressed image ( JPEG Extended (Process 2 and 4)) problems HOT 7
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 pylibjpeg.