You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-3
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
6
6
## pylibjpeg
7
7
8
-
A Python 3.6+ framework for decoding JPEG images and decoding/encoding RLE datasets, with a focus on providing support for [pydicom](https://github.com/pydicom/pydicom).
8
+
A Python 3.7+ framework for decoding JPEG images and decoding/encoding RLE datasets, with a focus on providing support for [pydicom](https://github.com/pydicom/pydicom).
9
9
10
10
11
11
### Installation
@@ -17,10 +17,16 @@ pip install pylibjpeg
17
17
18
18
##### Installing extra requirements
19
19
20
-
The package can be installed with extra requirements `openjpeg` or `rle`to enable support for JPEG-2000 and Run-Length Encoding (RLE), respectively:
20
+
The package can be installed with extra requirements to enable support for JPEG (with `libjpeg`), JPEG 2000 (with `openjpeg`) and Run-Length Encoding (RLE) (with `rle`), respectively:
Copy file name to clipboardExpand all lines: docs/plugins.md
+47-7
Original file line number
Diff line number
Diff line change
@@ -24,19 +24,43 @@ setup(
24
24
25
25
#### Decoder function signature
26
26
27
-
The pixel data decoding function will be passed two required parameters:
27
+
The pixel data decoding function will be passed one required parameter:
28
28
29
29
**src*: a single encoded image frame as [bytes](https://docs.python.org/3/library/stdtypes.html#bytes)
30
+
31
+
And at least one of:
30
32
**ds*: a *pydicom*[Dataset](https://pydicom.github.io/pydicom/stable/reference/generated/pydicom.dataset.Dataset.html) object containing the (0028,eeee) elements corresponding to the pixel data
33
+
**kwargs*: a dict with at least the following keys:
34
+
*`"transfer_syntax_uid": pydicom.uid.UID` - the *Transfer Syntax UID* of
35
+
the encoded data.
36
+
*`'rows': int` - the number of rows of pixels in the *src*.
37
+
*`'columns': int` - the number of columns of pixels in the
38
+
*src*.
39
+
*`'samples_per_pixel': int` - the number of samples used per
40
+
pixel, e.g. `1` for grayscale images or `3` for RGB.
41
+
*`'bits_allocated': int` - the number of bits used to contain
42
+
each pixel in *src*, should be 8, 16, 32 or 64.
43
+
*`'bits_stored': int` - the number of bits actually used by
44
+
each pixel in *src*.
45
+
*`'bits_stored': int` - the number of bits actually used by
46
+
each pixel in *src*, e.g. 12-bit pixel data (range 0 to 4095) will be
47
+
contained by 16-bits (range 0 to 65535).
48
+
*`'pixel_representation': int` - the type of data in *src*,
49
+
`0` for unsigned integers, `1` for 2's complement (signed)
50
+
integers.
51
+
*`'photometric_interpretation': str` - the color space
52
+
of the encoded data, such as `'YBR_FULL'`.
53
+
54
+
Other decoder-specific optional keyword parameters may also be present.
31
55
32
56
The function should return the decoded pixel data as a one-dimensional numpy [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html) of little-endian ordered `'uint8'`, with the data ordered from left-to-right, top-to-bottom (i.e. the first byte corresponds to the upper left pixel and the last byte corresponds to the lower-right pixel) and a planar configuration that matches
33
57
the requirements of the transfer syntax:
34
58
35
59
```python
36
60
defmy_pixel_data_decoder(
37
-
src: bytes, ds: pydicom.dataset.Dataset, **kwargs
61
+
src: bytes, ds: Optional[pydicom.dataset.Dataset] =None, **kwargs: Any
38
62
) -> numpy.ndarray:
39
-
"""Return the encoded `src` as an unshaped numpy ndarray of uint8.
63
+
"""Return the encoded *src* as an unshaped numpy ndarray of uint8.
40
64
41
65
.. versionchanged:: 1.3
42
66
@@ -46,11 +70,27 @@ def my_pixel_data_decoder(
46
70
----------
47
71
src : bytes
48
72
A single frame of the encoded *Pixel Data*.
49
-
ds : pydicom.dataset.Dataset
73
+
ds : pydicom.dataset.Dataset, optional
50
74
A dataset containing the group ``0x0028`` elements corresponding to
51
-
the *Pixel Data*.
52
-
kwargs
53
-
Optional keyword parameters for the decoder.
75
+
the *Pixel Data*. If not used then *kwargs* must be supplied.
76
+
kwargs : Dict[str, Any]
77
+
A dict containing relevant image pixel module elements:
78
+
79
+
* "rows": int - the number of rows of pixels in *src*, maximum 65535.
80
+
* "columns": int - the number of columns of pixels in *src*, maximum
81
+
65535.
82
+
* "number_of_frames": int - the number of frames in *src*.
83
+
* "samples_per_pixel": int - the number of samples per pixel in *src*,
84
+
should be 1 or 3.
85
+
* "bits_allocated": int - the number of bits used to contain each
86
+
pixel, should be a multiple of 8.
87
+
* "bits_stored": int - the number of bits actually used per pixel.
88
+
* "pixel_representation": int - the type of data being decoded, 0 for
89
+
unsigned, 1 for 2's complement (signed)
90
+
* "photometric_interpretation": the color space of the *encoded* pixel
0 commit comments