Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion committed Mar 23, 2024
1 parent 262d884 commit 7a18225
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Encoding of NumPy ndarrays is supported for the following:
* Number of rows/columns: up to 65535
* Number of planes: 1, 3 or 4





### Transfer Syntaxes
| UID | Description |
| --- | --- |
Expand Down Expand Up @@ -132,4 +128,4 @@ encode_array(arr, signal_noise_ratios=[50, 80, 100])

See the docstring for the [encode_array() function][2] for full details.

[2]: https://github.com/pydicom/pylibjpeg-openjpeg/blob/main/openjpeg/utils.py#L431
[2]: https://github.com/pydicom/pylibjpeg-openjpeg/blob/main/openjpeg/utils.py#L429
4 changes: 2 additions & 2 deletions lib/interface/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ extern int EncodeBuffer(
The image data to be encoded, as a little endian and colour-by-pixel
ordered bytes or bytearray.
columns : int
Supported values: 1-2^24 - 1
Supported values: 1-2^16 - 1
rows : int
Supported values: 1-2^24 - 1
Supported values: 1-2^16 - 1
samples_per_pixel : int
Supported values: 1, 3, 4
bits_stored : int
Expand Down
20 changes: 7 additions & 13 deletions openjpeg/_openjpeg.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def encode_array(
The number of bits used per pixel.
photometric_interpretation : int
The colour space of the unencoded image data that will be set in the
JPEG 2000 metadata.
JP2 metadata (if `codec_format` is ``1``).
use_mct : bool
If ``True`` then apply multi-component transformation (MCT) to RGB
images.
Expand Down Expand Up @@ -347,29 +347,23 @@ def encode_buffer(
A bytes or bytearray containing the image data to be encoded, ordered as
little endian and colour-by-pixel.
columns : int
The number of columns in the image, should be in the range (1, 16777215).
The number of columns in the image, should be in the range [1, 65535].
rows : int
The number of rows in the image, should be in the range (1, 16777215).
The number of rows in the image, should be in the range [1, 65535].
samples_per_pixel : int
The number of samples per pixel, should be 1, 3 or 4.
bits_stored : int
The number of bits used per pixel (i.e. the sample precision), should be
in the range (1, 24).
in the range [1, 24].
is_signed: int
``0`` if the image uses unsigned pixels, ``1`` for signed.
photometric_interpretation : int
The colour space of the unencoded image data that will be set in the
JPEG 2000 metadata, should be in the range (0, 5):
``0``: OPJ_CLRSPC_UNSPECIFIED
``1``: OPJ_CLRSPC_SRGB
``2``: OPJ_CLRSPC_GRAY
``3``: OPJ_CLRSPC_SYCC
``4``: OPJ_CLRSPC_EYCC
``5``: OPJ_CLRSPC_CMYK
JP2 metadata (if `codec_format` is ``1``).
use_mct : bool
If ``1`` then apply multi-component transformation (MCT) to RGB
images. Requires a `photometric_interpretation` of ``1`` and a
`samples_per_pixel` value of ``3``.
`samples_per_pixel` value of ``3``, otherwise no MCT will be used.
compression_ratios : list[float]
Required for lossy encoding, this is the compression ratio to use
for each quality layer. Cannot be used with `signal_noise_ratios`.
Expand All @@ -380,7 +374,7 @@ def encode_buffer(
The codec to used when encoding:

* ``0``: JPEG 2000 codestream only (default) (J2K/J2C format)
* ``2``: A boxed JPEG 2000 codestream (JP2 format)
* ``1``: A boxed JPEG 2000 codestream (JP2 format)

Returns
-------
Expand Down
10 changes: 5 additions & 5 deletions openjpeg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def encode_array(
signal_noise_ratios: Union[List[float], None] = None,
codec_format: int = 0,
**kwargs: Any,
) -> Union[bytes, bytearray]:
) -> bytes:
"""Return the JPEG 2000 compressed `arr`.
Encoding of the input array will use lossless compression by default, to
Expand All @@ -456,7 +456,7 @@ def encode_array(
Lossless compression will use the following:
* DWT 5-7 with reversible component transformation
* DWT 5-3 with reversible component transformation
* 1 quality layer
Lossy compression will use the following:
Expand Down Expand Up @@ -580,7 +580,7 @@ def encode_buffer(
signal_noise_ratios: Union[List[float], None] = None,
codec_format: int = 0,
**kwargs: Any,
) -> Union[bytes, bytearray]:
) -> bytes:
"""Return the JPEG 2000 compressed `src`.
.. versionadded:: 2.2
Expand All @@ -599,7 +599,7 @@ def encode_buffer(
Lossless compression will use the following:
* DWT 5-7 with reversible component transformation
* DWT 5-3 with reversible component transformation
* 1 quality layer
Lossy compression will use the following:
Expand Down Expand Up @@ -714,7 +714,7 @@ def encode_buffer(

def encode_pixel_data(
src: Union[bytes, bytearray], **kwargs: Any
) -> Union[bytes, bytearray]:
) -> bytes:
"""Return the JPEG 2000 compressed `src`.
.. versionadded:: 2.2
Expand Down

0 comments on commit 7a18225

Please sign in to comment.